//vue-cli3.0 vue-config.js
//npm install terser-webpack-plugin --save-dev
const TerserPlugin = require('terser-webpack-plugin')
module.exports = {
configureWebpack: config => {
config
.optimization = {
minimizer: [
new TerserPlugin({
terserOptions: {
compress: {
drop_console: true
}
}
})
]
}
}
}
//vue-cli2.0 webpack.prod.conf.js
//npm install uglifyjs-webpack-plugin --save-dev
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
plugins: [
// http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({
'process.env': env
}),
new UglifyJsPlugin({
uglifyOptions: {
// include: /\/src/,
compress: {
warnings: false,
drop_debugger: true, //自动删除debugger
drop_console: true //自动删除console.log
}
},
sourceMap: config.build.productionSourceMap,
parallel: true
}),
......
网友评论