webpack区分不同环境下的打包方式

区分不同环境

新建两个配置文件, webpack.prod.js webpack.dev.js
使用webpack-merge来进行合并

yarn add webpack-merge -D

// webpack.prod.js

let {
     smart} = require('webpack-merge');
let base = require('./webpack.config.js');

module.exports = smart(base, {
     
   mode: 'production',
});

// webpack.dev.js

let {
     smart} = require('webpack-merge');
let base = require('./webpack.config.js');

module.exports = smart(base, {
     
   mode: 'development',
});

你可能感兴趣的:(webpack系列,webpack-merge,webpack,webpack区分环境)