webpack-merge
介绍
语法
const Merge = require('webpack-merge');
const Base = require('./webpack.config.base.js');
const Development = {
}
module.exports = Merge.merge(Base,Development);
关联
Vue-Cli 与 webpack-merge
Vue-cli 中configureWebpack
选项是通过webpack-merge
来维护的
- 对象写法
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
new MyAwesomeWebpackPlugin()
]
}
}
- 函数写法
// vue.config.js
module.exports = {
configureWebpack: config => {
if (process.env.NODE_ENV === 'production') {
// 为生产环境修改配置...
} else {
// 为开发环境修改配置...
}
}
}