最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What does require('path'); means in Webpack.config.js? - Stack Overflow

programmeradmin3浏览0评论

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'
     }
 };

.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.

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.

Share Improve this question edited Nov 23, 2017 at 15:17 Gopinath Kaliappan asked Nov 23, 2017 at 15:15 Gopinath KaliappanGopinath Kaliappan 7,3598 gold badges41 silver badges60 bronze badges 1
  • 2 I suppose it's this – Federico klez Culloca Commented Nov 23, 2017 at 15:16
Add a comment  | 

1 Answer 1

Reset to default 19

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

发布评论

评论列表(0)

  1. 暂无评论