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. 'lodash',
  7. 'react-hot-loader/babel',
  8. '@babel/plugin-syntax-dynamic-import',
  9. '@babel/plugin-proposal-object-rest-spread',
  10. '@babel/plugin-transform-runtime',
  11. // NOTE: The order of the decorator and class-property plugins is important
  12. // here. Decorators must be processed first before class properties, see:
  13. // https://babeljs.io/docs/en/plugins#plugin-ordering
  14. ['@babel/plugin-proposal-decorators', {legacy: true}],
  15. ['@babel/plugin-proposal-class-properties', {loose: true}],
  16. ],
  17. env: {
  18. production: {
  19. plugins: [
  20. [
  21. 'transform-react-remove-prop-types',
  22. {
  23. mode: 'remove', // remove from bundle
  24. removeImport: true, // removes `prop-types` import statements
  25. classNameMatchers: [
  26. 'SelectField',
  27. 'FormField',
  28. 'AsyncComponent',
  29. 'AsyncView',
  30. ],
  31. additionalLibraries: [/app\/sentryTypes$/],
  32. },
  33. ],
  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. };