Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
50
rated 0 times [  56] [ 6]  / answers: 1 / hits: 16211  / 7 Years ago, thu, november 23, 2017, 12:00:00

I was configuring webpack configuration with my own instead of copy things and paste , I just need to understand each and every line in Webpack configuration file.



What is the use of the first line require('path') in webpack Configuration File.



const path = require('path');

module.exports = {
entry: './src/app.js',
output: {
path: path.resolve(__dirname, 'bin'),
filename: 'app.bundle.js'
}
};


https://webpack.github.io/docs/usage.html
I am following the above link to getting things started



in the module.exports , path has been used but i did not get any idea in the usage of the path. Please let me know the usage. So i can start further.


More From » webpack

 Answers
10

path is Node.js native utility module.



https://nodejs.org/api/path.html



require is Node.js global function that allows you to extract contents from module.exports object inside some file.



Unlike regular NPM modules, you don't need to install it because it's already inside Node.js



In your example you use path.resolve method which creates proper string representing path to your file.



Straight from docs:




The path.resolve() method resolves a sequence of paths or path
segments into an absolute path.




https://nodejs.org/api/path.html#path_path_resolve_paths


[#55853] Tuesday, November 21, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
raveno

Total Points: 453
Total Questions: 92
Total Answers: 92

Location: France
Member since Thu, Oct 27, 2022
2 Years ago
raveno questions
;