我正在使用 Vue CLI 3,我需要添加Terser Webpack 插件以从代码中删除console.log和注释。这不适用于我当前的设置 - 日志和评论仍在构建中。我的生产流程:
npm run buildserve -s dist vue.config.js:
module.exports = {
publicPath: "./"
}
Run Code Online (Sandbox Code Playgroud)
webpack.config.js:
const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
ecma: undefined,
warnings: false,
parse: {},
compress: { drop_console: true },
mangle: true, // Note `mangle.properties` is `false` by default.
module: false,
output: { comments: false },
toplevel: false,
nameCache: null,
ie8: false, …Run Code Online (Sandbox Code Playgroud)