javascript - Difference between foo.join and foo.resolve? In webpack -


i come ruby on rails background , know if i'm understanding following code correctly...

currently webpack.config.js looks below...

var path = require('path');  module.exports = {   context: path.join(__dirname, 'src'),   entry: [     './app.js'   ],   ... etc 

what difference if did

... (omitted code)    context: path.resolve(__dirname, '../src'),  ... etc 

does resolve file in directory , if doesn't exist creates me? sort of if defined in ruby

thanks , sorry stupid question.

path.join string concatenation using correct directory delimiters host operating system (usually / or \). path.resolve same thing but figures out absolute path, starting root directory of system.

in case, resulting path same because __dirname absolute path, simple concatenation path.join produces same result path.resolve guarantees absolute path.

neither method create directories or files don't exist - give path string regardless of whether can reached there.

edit: note path.join , path.resolve methods of nodejs path module docs - not general javascript methods


Comments