webpack项目打包清除console.log插件

插件名: babel-plugin-transfrom-remove-console

运行安装命令:

npm install babel-plugin-transform-remove-console --save-dev

如果是vue-cli4版本的脚手架工具,直接打开babel.config.js 文件在plugins 中添加

 'plugins': [
    "transform-remove-console"
  ]

具体配置:

const prodPlugins = []
// 如果是发布模式则启用的插件
if (process.env.NODE_ENV === 'production') {
  prodPlugins.push('transform-remove-console')
}

module.exports = {
  presets: [
    '@vue/cli-plugin-babel/preset'
  ],
  plugins: [
    ...prodPlugins
  ]
}

猜你喜欢

转载自www.cnblogs.com/liea/p/11853502.html