1.两种方式分离配置文件
//法一:直接指定配置文件
//package.json
"scripts": {
"serve": "webpack serve --open --config ./config/webpack.dev.js",
"build":"webpack --config ./config/webpack.prod.js"
}
//法二:给一个配置文件传递参数
//package.json
"scripts": {
"serve": "webpack serve --open --config ./config/webpack.common.js --env developent",
"build":"webpack --config ./configwebpack.common.js --env production"
}
//webpack.common.js
module.exports=function (env) {
console.log(env); //env对象会含有上面package.json中的env后面的参数
return{
entry:...
}
}
2.webpack.config.js中的context属性
//package.json
"scripts": {
"serve": "webpack serve --open --config ./config/webpack.common.js --env developent",
"build":"webpack --config ./config/webpack.common.js --env production"
}
//webpack.common.js
module.exports={
mode:"