I looked at the webpack.config.js of some projects, and they all use path.resolve()
webpack.config.js
path.resolve()
I don’t understand why this is the case. Why not use relative paths directly?
Solution.
Portability, because a configuration file may be divided into many parts and then included. And most of the time, each part may be in other directories for neat structure.
@justjavac I have the same question, can you give me a more detailed answer on the first floor, or give me a reference link
If you use a relative path, you will be in trouble if you change the file location
Platform-independent, flexible, and convenient. The path.resolve() method is an API provided by node and is easy to use.
Portability, because a configuration file may be divided into many parts and then included. And most of the time, each part may be in other directories for neat structure.
@justjavac I have the same question, can you give me a more detailed answer on the first floor, or give me a reference link
If you use a relative path, you will be in trouble if you change the file location
Platform-independent, flexible, and convenient. The path.resolve() method is an API provided by node and is easy to use.