babel.config.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*eslint-env node*/
  2. module.exports = {
  3. presets: ['@babel/react', '@babel/env', '@babel/preset-typescript'],
  4. plugins: [
  5. 'emotion',
  6. 'react-hot-loader/babel',
  7. '@babel/plugin-syntax-dynamic-import',
  8. '@babel/plugin-proposal-object-rest-spread',
  9. '@babel/plugin-transform-runtime',
  10. // NOTE: The order of the decorator and class-property plugins is important
  11. // here. Decorators must be processed first before class properties, see:
  12. // https://babeljs.io/docs/en/plugins#plugin-ordering
  13. ['@babel/plugin-proposal-decorators', {legacy: true}],
  14. ['@babel/plugin-proposal-class-properties', {loose: true}],
  15. ],
  16. env: {
  17. production: {
  18. plugins: [
  19. [
  20. 'transform-react-remove-prop-types',
  21. {
  22. mode: 'remove', // remove from bundle
  23. removeImport: true, // removes `prop-types` import statements
  24. classNameMatchers: [
  25. 'SelectField',
  26. 'FormField',
  27. 'AsyncComponent',
  28. 'AsyncView',
  29. ],
  30. additionalLibraries: [/app\/sentryTypes$/],
  31. },
  32. ],
  33. ['babel-plugin-add-react-displayname'],
  34. ],
  35. },
  36. development: {
  37. plugins: [
  38. ['emotion', {sourceMap: true, autoLabel: true}],
  39. '@babel/plugin-transform-react-jsx-source',
  40. ],
  41. },
  42. test: {
  43. plugins: [['emotion', {autoLabel: true}], 'dynamic-import-node'],
  44. },
  45. },
  46. };