- Install the Terser-webpack-plugin
npm install terser-webpack-plugin --save-dev
Copy the code
- using
chainWebpack
Chain calls
// vue.config.js
module.exports = {
chainWebpack(config){ config .when(process.env.NODE_ENV ! = ='development'.config= > {
config.optimization
.minimizer('terser')
.tap(options= > {
options[0].terserOptions.compress.drop_console = true
return options
})
})
},
}
Copy the code