https://github.com/webpack-contrib/terser-webpack-plugin
https://stackoverflow.com/questions/57360588/how-to-use-terser-with-webpack
https://juejin.im/post/5cbc40ea6fb9a068b65e2aa6
npm install npm install terser-webpack-plugin
vue.config.js
const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
chainWebpack: process.env.NODE_ENV === 'production'
? config => {
config.module.rules.delete('eslint');
config.optimization.minimizer([
new TerserPlugin({
terserOptions: {
parse: {
ecma: 8
},
compress: {
ecma : 5,
warnings : false,
comparisons: false,
inline : 2
},
mangle: {
reserved: ["BigInteger","ECPair","Point"],
safari10: true
},
output: {
ecma : 5,
comments : false,
ascii_only: true
}
},
cache: true,
parallel: true,
sourceMap: false, // false 可以減少一半的js大小,sourceMap為除錯使用
})
]);
}
: config => {
config.module.rules.delete('eslint');
},
devServer: {
host: '0.0.0.0',
port: '80',
//public: '0.0.0.0:80', //無效
disableHostCheck: true,
}
}