2
0

babel.config.js 1019 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. module.exports = api => {
  2. api.cache.using(() => process.env.NODE_ENV);
  3. const common = {
  4. presets: [
  5. ["@babel/env", { targets: { node: "current" } }],
  6. "@babel/typescript",
  7. "@babel/react",
  8. ],
  9. plugins: [
  10. [
  11. "@babel/plugin-proposal-decorators",
  12. {
  13. legacy: true,
  14. },
  15. ],
  16. "@babel/proposal-class-properties",
  17. "@babel/proposal-object-rest-spread",
  18. "@babel/plugin-proposal-optional-chaining",
  19. ],
  20. };
  21. if (process.env.NODE_ENV === "development") {
  22. common.plugins.push([
  23. "react-refresh/babel",
  24. {
  25. skipEnvCheck: true,
  26. },
  27. ]);
  28. }
  29. if (
  30. process.env.NODE_ENV === "development" ||
  31. process.env.NODE_ENV === "test"
  32. ) {
  33. common.plugins.push([
  34. "babel-plugin-styled-components",
  35. { displayName: true, minify: false },
  36. ]);
  37. } else {
  38. common.plugins.push([
  39. "babel-plugin-styled-components",
  40. { displayName: false, minify: true },
  41. ]);
  42. }
  43. return common;
  44. };