安装 uglifyjs-webpack-plugin

npm install uglifyjs-webpack-plugin --save-dev

vue.config.js

const UglifyJsPlugin = require('uglifyjs-webpack-plugin') //引入插件
configureWebpack: {
    // provide the app's title in webpack's name field, so that
    // it can be accessed in index.html to inject the correct title.
    
    optimization: {
      minimizer: [
        new UglifyJsPlugin({
          uglifyOptions: {
            // 删除注释
            output: {
              comments: false
            },
            // 删除console debugger 删除警告
            compress: {
              drop_console: true, //console
              drop_debugger: false,
              pure_funcs: ['console.log'] //移除console
            }
          }
        })
      ]
    }
  },

标签: none

添加新评论