美文网首页
vuecli生产环境 移除conso.log()

vuecli生产环境 移除conso.log()

作者: 子绎 | 来源:发表于2020-10-27 09:26 被阅读0次

    在vue.config.js(没有的话就在项目目录新建一个)中写入

    const TerserPlugin = require("terser-webpack-plugin");
    module.exports = {
      configureWebpack: {
        optimization: {
          minimizer: [
            new TerserPlugin({
              terserOptions: {
                ecma: undefined,
                warnings: false,
                parse: {},
                compress: {
                  drop_console: true,
                  drop_debugger: false,
                  pure_funcs: ['console.log'] // 移除console
                }
              },
            }),
          ]
        }
      },
    }
    

    相关文章

      网友评论

          本文标题:vuecli生产环境 移除conso.log()

          本文链接:https://www.haomeiwen.com/subject/ruptvktx.html