Vue-cli3.0配置打包之后的打印

1.安装插件
cnpm install babel-plugin-transform-remove-console
2.在babel.config.js进行配置

const plugins = []
if (process.env.NODE_ENV === 'production') {
  plugins.push('transform-remove-console')
}
module.exports = {
  presets: [
    '@vue/app'
  ],
  plugins
}

ps如果不想清除console.error和console.warn

const plugins = []
if (process.env.NODE_ENV === 'production') {
//exclude(忽略)
  plugins.push(["transform-remove-console", { "exclude": [ "error", "warn"] }])
}
module.exports = {
  presets: [
    '@vue/app'
  ],
  plugins
}

你可能感兴趣的:(Vue-cli3.0配置打包之后的打印)