babel.config.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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: [['babel-plugin-add-react-displayname']],
  27. },
  28. development: {
  29. plugins: [
  30. '@emotion/babel-plugin',
  31. '@babel/plugin-transform-react-jsx-source',
  32. ...(process.env.SENTRY_UI_HOT_RELOAD ? ['react-refresh/babel'] : []),
  33. ],
  34. },
  35. test: {
  36. sourceMaps: process.env.CI ? false : true,
  37. plugins: [
  38. // Disable emotion sourcemaps in tests
  39. // Since emotion spends lots of time parsing and inserting sourcemaps
  40. [
  41. '@emotion/babel-plugin',
  42. {
  43. sourceMap: false,
  44. },
  45. ],
  46. ],
  47. },
  48. },
  49. };
  50. export default config;