Module Path:
Path.normalize (url)
Path.join (url1, Url2,..)
Path.resolve (url1, Url2,..)
Path.relative (url1, Url2)
Path.dirname (url)
Path.basename (url)
Path.extname (url)
TIPS:
The above is the path Object's api, the invocation is convenient and concise, generally in the project I will first write a top-level directory
var publicdir = path.resolve (__dirname, './src ')
The remaining subdirectories are derived from this top-level directory
var pagesdir = path.resolve (publicdir, './pages ')var staticdir = Path.resolve ( publicdir, '. Static ')var buildDir = path.resolve (publicdir, './build ')var Vendordir = path.resolve (publicdir, './vendor ')
finally, The object is mounted, other files need to be used to the path, the direct introduction of the
Module.exports = { pagesdir: './pages ') staticdir: '. static ') BuildDir : './build ') vendordir: './vendor ')}
API Example:
varPath = require (' path ');/** Format Path:. /return to the previous level, so the result is *--'/foo/bar/baz/asdf '*/Path.normalize ('/foo/bar//baz/asdf/quux/. ');/** Stitching Path: after stitching is completed call normalize (), results same as *---'/FOO/BAR/BAZ/ASDF '*/Path.join ('///foo ', ' bar ', '//baz/asdf ', ' Quux ', ' ... ');/** Path navigation: equals CD once per Sub-path*/Path.resolve (' Foo/bar ', '/tmp/file/', ' ... ', ' a '. /subfile ')/** Relative Path: b The path relative to a is: '. /.. /IMPL/BBB ', The result on a path can be accessed to the B file *--and '. /.. /IMPL/BBB '*/path.relative ('/DATA/ORANDEA/TEST/AAA ', '/data/orandea/impl/bbb ')/** Folder name: the name of the path where the folder is located *--'/foo/bar/baz/asdf '*/Path.dirname ('/foo/bar/baz/asdf/quux ') /** File Path: returns the specified file name to exclude the suffix name *--' quux '*/Path.basename ('/foo/bar/baz/asdf/quux.html ', '. html ')/** Extension name: return file extension*/Path.extname (' Index.html ')//'. html 'Path.extname (' Index. ')//'. 'Path.extname (' Index ')//"'Module.exports={entry: [], output:{path:builddir, filename:' [name]/entry.js ' }};
Nodejs:path Object