首先需要先安装webpack-merge;然后引入smart方法,
import {smart} require('./webpack-merge')
- webpack.dev.js放开发阶段的配置
- webpack.prod.js放生产阶段的配置
- webpack.common.js放公共的配置
- 在 webpack.dev.js(或webpack.prod.js)中引入webpack.common.js文件,通过smart合并配置
webpackCommonConf就是引入的webpack.common.js
module.exports=smart(webpackCommonConf,{
//公共配置
}}