babel.config.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import type {TransformOptions} from '@babel/core';
  2. const config: TransformOptions = {
  3. presets: [
  4. [
  5. '@babel/preset-react',
  6. {
  7. runtime: 'automatic',
  8. importSource: '@emotion/react',
  9. },
  10. ],
  11. [
  12. '@babel/preset-env',
  13. {
  14. useBuiltIns: 'usage',
  15. corejs: '3.37',
  16. },
  17. ],
  18. // TODO: Remove allowDeclareFields when we upgrade to Babel 8
  19. ['@babel/preset-typescript', {allowDeclareFields: true}],
  20. ],
  21. overrides: [],
  22. plugins: ['@emotion/babel-plugin', '@babel/plugin-transform-runtime'],
  23. env: {
  24. production: {
  25. plugins: [['babel-plugin-add-react-displayname']],
  26. },
  27. development: {
  28. plugins: [
  29. '@emotion/babel-plugin',
  30. '@babel/plugin-transform-react-jsx-source',
  31. ...(process.env.SENTRY_UI_HOT_RELOAD ? ['react-refresh/babel'] : []),
  32. ],
  33. },
  34. test: {
  35. sourceMaps: process.env.CI ? false : true,
  36. plugins: [
  37. // Disable emotion sourcemaps in tests
  38. // Since emotion spends lots of time parsing and inserting sourcemaps
  39. [
  40. '@emotion/babel-plugin',
  41. {
  42. sourceMap: false,
  43. },
  44. ],
  45. ],
  46. },
  47. },
  48. };
  49. export default config;