Vue打包时候build移除左右的console
推荐插件: babel-plugin-transform-remove-console Install: npm install babel-plugin-transform-remove-console --save-dev 通过 .babelrc (推荐) vue-cli3.0/babel.config.js中定义 plugins:[] // without options 这个就可以 { "plugins": ["transform-remove-console"] } // with options { "plugins": [ ["transform-remove-console", { "exclude": [ "error", "warn"] }] ] } module.exports = { 'presets': [ '@vue/app' ], 'plugins': [ [ 'component', { 'libraryName': 'element-ui', 'styleLibraryName': 'theme-chalk' } ], transform-remove-console ] } 如果只想在发布阶段生效,开发阶段不生效,需要判断: // 项目开发阶段用到的babel插件 const prodPlugins = [] if (process.env