babel.config.js 778 B

1234567891011121314151617181920212223242526
  1. module.exports = (api) => {
  2. const targets = {}
  3. if (api.env('test')) {
  4. targets.node = 'current'
  5. }
  6. return {
  7. presets: [
  8. ['@babel/preset-env', {
  9. include: [
  10. '@babel/plugin-proposal-nullish-coalescing-operator',
  11. '@babel/plugin-proposal-optional-chaining',
  12. ],
  13. loose: true,
  14. targets,
  15. useBuiltIns: false, // Don't add polyfills automatically.
  16. // We can uncomment the following line if we start adding polyfills to the non-legacy dist files.
  17. // corejs: { version: '3.15', proposals: true },
  18. }],
  19. ],
  20. plugins: [
  21. ['@babel/plugin-transform-react-jsx', { pragma: 'h' }],
  22. process.env.NODE_ENV !== 'dev' && 'babel-plugin-inline-package-json',
  23. ].filter(Boolean),
  24. }
  25. }