webpack --mode production code example
Example 1: webpack merge
npm install --save-dev webpack-merge
const { merge } = require('webpack-merge');
Example 2: set env production webpack build
// webpack.config.js
module.exports = env => {
const isProduction = env.NODE_ENV === 'production'
// ...
return {
// ...
}
}
// package.json
{
...
"scripts": {
"build": "webpack --env.NODE_ENV=production"
},
...
}