I was going though this webpack tutorial: https://youtu.be/TOb1c39m64A
At around 1:30:00 mark he discusses the use of __dirname in path.resolve however I don't quite understand what's the difference between using and not using it.
Dont they both (path.resolve & __dirname) mean the same thing? Both give the current absolute directory where this file is running. This is confirmed by the fact that when I remove __dirname it still creates the build files at same root location (even if the webpack.config.js) file is not present at the root level. i.e. both the below codes yield same result:
With __dirname
output: {
assetModuleFilename: "images/[hash][ext][query]",
path: path.resolve(__dirname, 'dist')
},
Without __dirname:
output: {
assetModuleFilename: "images/[hash][ext][query]",
path: path.resolve('dist')
},
So what is the need to use __dirname here??