babel.config.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*eslint-env node*/
  2. module.exports = {
  3. presets: [
  4. '@babel/react',
  5. '@babel/env',
  6. '@babel/preset-typescript',
  7. [
  8. '@emotion/babel-preset-css-prop',
  9. {
  10. autoLabel: true,
  11. sourceMap: false,
  12. labelFormat: '[local]',
  13. },
  14. ],
  15. ],
  16. plugins: [
  17. '@babel/plugin-syntax-dynamic-import',
  18. '@babel/plugin-proposal-object-rest-spread',
  19. '@babel/plugin-transform-runtime',
  20. // NOTE: The order of the decorator and class-property plugins is important
  21. // here. Decorators must be processed first before class properties, see:
  22. // https://babeljs.io/docs/en/plugins#plugin-ordering
  23. ['@babel/plugin-proposal-decorators', {legacy: true}],
  24. ['@babel/plugin-proposal-class-properties', {loose: true}],
  25. ],
  26. env: {
  27. production: {
  28. plugins: [
  29. [
  30. 'transform-react-remove-prop-types',
  31. {
  32. mode: 'remove', // remove from bundle
  33. removeImport: true, // removes `prop-types` import statements
  34. classNameMatchers: [
  35. 'SelectField',
  36. 'FormField',
  37. 'AsyncComponent',
  38. 'AsyncView',
  39. ],
  40. additionalLibraries: [/app\/sentryTypes$/],
  41. },
  42. ],
  43. ['babel-plugin-add-react-displayname'],
  44. ],
  45. },
  46. development: {
  47. presets: [
  48. [
  49. '@emotion/babel-preset-css-prop',
  50. {
  51. autoLabel: true,
  52. sourceMap: false,
  53. },
  54. ],
  55. ],
  56. plugins: [
  57. '@babel/plugin-transform-react-jsx-source',
  58. !!process.env.SENTRY_UI_HOT_RELOAD ? 'react-refresh/babel' : null,
  59. ].filter(Boolean),
  60. },
  61. test: {
  62. plugins: ['dynamic-import-node'],
  63. },
  64. },
  65. };