webpack配置之webpack.config.js文件配置
webpack.config.js webpack resolve
1.总是手动的输入webpack的输入输出文件路径,是一件非常繁琐的事情。我们尝试用文件的形式将输入输出文件夹配置好。新建一个js文件,并命名为webpack.config.js【目前只能命名为这个,不然程序不识别】
webpack.config.js
2.在webpack.config.js文件内输入以下代码
module.exports = {
entry: './src/main.js', //打包文件入口
output: { //打包文件出口
path: './dist',
filename: 'bundle.js'
}
}
3.由于已经配置好输入输出文件夹,可以直接输入webpack运行指令,但是程序报错。
输入webpac程序报错
nvalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
The output directory as absolute path (required)"./dist" is not an absolute path!
The output directory as absolute path (required) #f00