Home  >  Q&A  >  body text

javascript - Why do some paths in webpack config use path.resolve?

I looked at the webpack.config.js of some projects, and they all use path.resolve()

I don’t understand why this is the case. Why not use relative paths directly?

Solution.

滿天的星座滿天的星座2712 days ago1380

reply all(4)I'll reply

  • 某草草

    某草草2017-05-18 10:48:05

    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.

    reply
    0
  • 怪我咯

    怪我咯2017-05-18 10:48:05

    @justjavac I have the same question, can you give me a more detailed answer on the first floor, or give me a reference link

    reply
    0
  • 怪我咯

    怪我咯2017-05-18 10:48:05

    If you use a relative path, you will be in trouble if you change the file location

    reply
    0
  • ringa_lee

    ringa_lee2017-05-18 10:48:05

    Platform-independent, flexible, and convenient. The path.resolve() method is an API provided by node and is easy to use.

    reply
    0
  • Cancelreply