只在发布阶段删除 console ,开发阶段不受影响

在babel.config.js 中修改

 1 // 这是项目发布阶段需要用到的 babel 插件
 2 const prodPlugins = []
 3 if (process.env.NODE_ENV === 'production') {
 4   prodPlugins.push('transform-remove-console')
 5 }
 6 
 7 module.exports = {
 8   presets: [
 9     '@vue/cli-plugin-babel/preset'
10   ],
11   plugins: [
12     [
13       'component',
14       {
15         libraryName: 'element-ui',
16         styleLibraryName: 'theme-chalk'
17       }
18     ],
19 
20     // 发布产品时候的插件数组
21     ...prodPlugins
22   ]
23 }

原文地址:https://www.cnblogs.com/ndh074512/p/14998611.html