本文共 898 字,大约阅读时间需要 2 分钟。
推荐插件:
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.NODE_ENV === 'production') { prodPlugins.push('transform-remove-console')}module.exports = { 'presets': [ '@vue/app' ], 'plugins': [ [ 'component', { 'libraryName': 'element-ui', 'styleLibraryName': 'theme-chalk' } ], // 发布产品时候的插件数组 ...prodPlugins ]}
转载地址:http://lnesi.baihongyu.com/