babel.config.ts 1.3 KB

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