vue cli 生产环境打包去除console
1. vue cli 2.x
/build/webpack.prod.conf.js
1 2 3 4 5 6 7 8 9
| new UglifyJsPlugin({ uglifyOptions: { compress: { warnings: false, drop_debugger: true, drop_console: true } } })
|
2.vue cli 3+
2.1 安装
1
| npm install terser-webpack-plugin --save-dev /cnpm .../ yarn add terser-webpack-plugin
|
2.2 配置
/vue.config.js
1 2 3 4 5 6 7
| module.export = { configureWebpack: (config)=>{ if(process.env.NODE_ENV === 'production'){ config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true } } }
|