module.exports = {
  presets: [
    [
      '@babel/preset-env',
      {
        'exclude': [
          'transform-typeof-symbol',
          'transform-unicode-regex',
          'transform-sticky-regex',
          'transform-new-target',
          'transform-modules-umd',
          'transform-modules-systemjs',
          'transform-modules-amd',
          'transform-literals',
        ],
        'modules': false,
      },
    ],
    ['@babel/preset-typescript'],
    ['@babel/preset-react'],
  ],
  plugins: [
    'styled-components',
    ['@babel/plugin-proposal-optional-chaining', { 'loose': false }],
    ['@babel/plugin-proposal-nullish-coalescing-operator', { 'loose': false }],
    '@babel/plugin-syntax-top-level-await',
    ['@babel/plugin-transform-destructuring', { 'loose': false }],
    ['@babel/plugin-proposal-decorators', { 'legacy': true }],
    ['@babel/plugin-proposal-class-properties', { 'loose': true }],
    '@babel/plugin-proposal-export-default-from',
    ['@babel/plugin-proposal-pipeline-operator', { 'proposal': 'minimal' }],
    '@babel/plugin-proposal-do-expressions',
    '@babel/plugin-proposal-function-bind',
    '@babel/plugin-proposal-logical-assignment-operators',
    '@babel/plugin-syntax-dynamic-import',
    ['babel-plugin-transform-react-remove-prop-types', { 'removeImport': true }],
    ['babel-plugin-react-require'],
    ['babel-plugin-import', { 'libraryName': 'antd', 'libraryDirectory': 'es', 'style': true }, 'antd'],
  ],
  env: {
    production: {
      only: ['src'],
      plugins: [
        'lodash',
        'transform-react-remove-prop-types',
        '@babel/plugin-transform-react-inline-elements',
        '@babel/plugin-transform-react-constant-elements'
      ],
    },
    development: {
      plugins: ['react-refresh/babel']
    },
    test: {
      plugins: ['@babel/plugin-transform-modules-commonjs', 'dynamic-import-node']
    },
  },
};
