babel.config.js 895 B

1234567891011121314151617181920212223242526
  1. const productionPlugins = []
  2. // 插件未安装时不阻断构建(需先 npm install)
  3. try {
  4. require.resolve('babel-plugin-transform-remove-console')
  5. productionPlugins.push(['transform-remove-console', { exclude: ['error'] }])
  6. } catch (e) {
  7. // babel-plugin-transform-remove-console 未安装,跳过
  8. }
  9. module.exports = {
  10. presets: [
  11. // https://github.com/vuejs/vue-cli/tree/master/packages/@vue/babel-preset-app
  12. '@vue/cli-plugin-babel/preset'
  13. ],
  14. 'env': {
  15. 'development': {
  16. // babel-plugin-dynamic-import-node plugin only does one thing by converting all import() to require().
  17. // This plugin can significantly increase the speed of hot updates, when you have a large number of pages.
  18. 'plugins': ['dynamic-import-node']
  19. },
  20. // M12: 生产环境移除 console(保留 error)
  21. 'production': {
  22. 'plugins': productionPlugins
  23. }
  24. }
  25. }