babel.config.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. 'react-hot-loader/babel',
  18. '@babel/plugin-syntax-dynamic-import',
  19. '@babel/plugin-proposal-object-rest-spread',
  20. '@babel/plugin-transform-runtime',
  21. // NOTE: The order of the decorator and class-property plugins is important
  22. // here. Decorators must be processed first before class properties, see:
  23. // https://babeljs.io/docs/en/plugins#plugin-ordering
  24. ['@babel/plugin-proposal-decorators', {legacy: true}],
  25. ['@babel/plugin-proposal-class-properties', {loose: true}],
  26. ],
  27. env: {
  28. production: {
  29. plugins: [
  30. [
  31. 'transform-react-remove-prop-types',
  32. {
  33. mode: 'remove', // remove from bundle
  34. removeImport: true, // removes `prop-types` import statements
  35. classNameMatchers: [
  36. 'SelectField',
  37. 'FormField',
  38. 'AsyncComponent',
  39. 'AsyncView',
  40. ],
  41. additionalLibraries: [/app\/sentryTypes$/],
  42. },
  43. ],
  44. ['babel-plugin-add-react-displayname'],
  45. ],
  46. },
  47. development: {
  48. presets: [
  49. [
  50. '@emotion/babel-preset-css-prop',
  51. {
  52. autoLabel: true,
  53. sourceMap: false,
  54. },
  55. ],
  56. ],
  57. plugins: ['@babel/plugin-transform-react-jsx-source'],
  58. },
  59. test: {
  60. plugins: ['dynamic-import-node'],
  61. },
  62. },
  63. };