2
0

babel.config.js 889 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. "react-hot-loader/babel",
  11. [
  12. "@babel/plugin-proposal-decorators",
  13. {
  14. legacy: true,
  15. },
  16. ],
  17. "@babel/proposal-class-properties",
  18. "@babel/proposal-object-rest-spread",
  19. "@babel/plugin-proposal-optional-chaining",
  20. ],
  21. };
  22. if (
  23. process.env.NODE_ENV === "development" ||
  24. process.env.NODE_ENV === "test"
  25. ) {
  26. common.plugins.push([
  27. "babel-plugin-styled-components",
  28. { displayName: true, minify: false },
  29. ]);
  30. } else {
  31. common.plugins.push([
  32. "babel-plugin-styled-components",
  33. { displayName: false, minify: true },
  34. ]);
  35. }
  36. return common;
  37. };