[英]What does require('path'); means in Webpack.config.js?
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. 我用自己配置webpack配置而不是复制东西和粘贴,我只需要了解Webpack配置文件中的每一行。
What is the use of the first line require('path') in webpack Configuration File. webpack配置文件中第一行require('path')的用途是什么。
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 https://webpack.github.io/docs/usage.html我按照上面的链接开始工作
in the module.exports , path has been used but i did not get any idea in the usage of the path. 在module.exports中 ,路径已被使用,但我对路径的使用没有任何想法。 Please let me know the usage.
请让我知道用法。 So i can start further.
所以我可以进一步开始。
path
is Node.js native utility module. path
是Node.js本机实用程序模块。
https://nodejs.org/api/path.html 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. require
是Node.js全局函数,允许您从某个文件中的module.exports
对象中提取内容。
Unlike regular NPM modules, you don't need to install it because it's already inside Node.js 与常规NPM模块不同,您不需要安装它,因为它已经在Node.js中
In your example you use path.resolve
method which creates proper string representing path to your file. 在您的示例中,您使用
path.resolve
方法,该方法创建表示文件路径的正确字符串。
Straight from docs: 直接来自docs:
The path.resolve() method resolves a sequence of paths or path segments into an absolute path.
path.resolve()方法将一系列路径或路径段解析为绝对路径。
https://nodejs.org/api/path.html#path_path_resolve_paths https://nodejs.org/api/path.html#path_path_resolve_paths
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.