babel.config配置打包生产包删除console

使用babel-plugin-transform-remove-console插件

安装依赖库

$ npm install babel-plugin-transform-remove-console --save-dev
# or
$  yarn add babel-plugin-transform-remove-console --dev

babel.config.js配置如下

const plugins = ["@vue/babel-plugin-transform-vue-jsx"]
// 生产环境移除console
if(process.env.NODE_ENV === 'production') {
  plugins.push("transform-remove-console")
}
module.exports = {
  plugins: plugins,
  presets: [
    [
      '@vue/app', {
        modules: false,
        targets: {
          browsers: ["> 1%", "last 2 versions", "not ie <= 8", "Android >= 4", "iOS >= 8"]
        },
        useBuiltIns: 'entry',
      }
    ]
  ]
}

你可能感兴趣的:(babel.config配置打包生产包删除console)