vue-cli3打包隐藏console配置

1. 通过npm安装插件

npm install terser-webpack-plugin --save-dev

2.配置vue.config.js

module.exports = {
  transpileDependencies: ["vuetify"],
  publicPath: "./",
  lintOnSave: false,
  configureWebpack: config => {
    if (process.env.NODE_ENV === "production") {
      config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true;
    }
  }
};

3.重新运行 npm run build 查看效果

你可能感兴趣的:(vue-cli3打包隐藏console配置)