babel.config.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. ['babel-plugin-add-react-displayname'],
  35. ],
  36. },
  37. development: {
  38. plugins: [
  39. ['emotion', {sourceMap: true, autoLabel: true}],
  40. '@babel/plugin-transform-react-jsx-source',
  41. ],
  42. },
  43. test: {
  44. plugins: [['emotion', {autoLabel: true}], 'dynamic-import-node'],
  45. },
  46. },
  47. };