babel.config.js 796 B

12345678910111213141516171819202122232425262728293031
  1. module.exports = api => {
  2. api.cache.using(() => process.env.NODE_MODE)
  3. const common = {
  4. presets: [
  5. ['@babel/env', { targets: { node: true } }],
  6. '@babel/typescript',
  7. '@babel/react',
  8. ],
  9. plugins: [
  10. 'react-hot-loader/babel',
  11. [
  12. '@babel/plugin-proposal-decorators',
  13. {
  14. legacy: true,
  15. },
  16. ],
  17. '@babel/proposal-class-properties',
  18. '@babel/proposal-object-rest-spread',
  19. '@babel/plugin-proposal-optional-chaining',
  20. ],
  21. }
  22. if (process.env.NODE_MODE === 'development') {
  23. common.plugins.push(['babel-plugin-styled-components', { displayName: true, minify: false }])
  24. } else {
  25. common.plugins.push(['babel-plugin-styled-components', { displayName: false, minify: true }])
  26. }
  27. return common
  28. }