babel.config.js 1.87 KB
Newer Older
Julien Benchetrit's avatar
Julien Benchetrit committed
1 2 3 4 5
module.exports = {
  presets: [
    [
      '@babel/preset-env',
      {
邓晓峰's avatar
邓晓峰 committed
6 7 8 9 10 11 12 13 14 15 16
        '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,
Julien Benchetrit's avatar
Julien Benchetrit committed
17 18
      },
    ],
邓晓峰's avatar
邓晓峰 committed
19 20
    ['@babel/preset-typescript'],
    ['@babel/preset-react'],
Julien Benchetrit's avatar
Julien Benchetrit committed
21 22 23
  ],
  plugins: [
    'styled-components',
邓晓峰's avatar
邓晓峰 committed
24 25 26 27 28 29 30 31 32 33 34
    ['@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',
Julien Benchetrit's avatar
Julien Benchetrit committed
35
    '@babel/plugin-syntax-dynamic-import',
邓晓峰's avatar
邓晓峰 committed
36 37 38
    ['babel-plugin-transform-react-remove-prop-types', { 'removeImport': true }],
    ['babel-plugin-react-require'],
    ['babel-plugin-import', { 'libraryName': 'antd', 'libraryDirectory': 'es', 'style': true }, 'antd'],
Julien Benchetrit's avatar
Julien Benchetrit committed
39 40 41
  ],
  env: {
    production: {
dengxiaofeng's avatar
dengxiaofeng committed
42
      only: ['src'],
Julien Benchetrit's avatar
Julien Benchetrit committed
43 44 45 46
      plugins: [
        'lodash',
        'transform-react-remove-prop-types',
        '@babel/plugin-transform-react-inline-elements',
邓晓峰's avatar
邓晓峰 committed
47
        '@babel/plugin-transform-react-constant-elements'
Julien Benchetrit's avatar
Julien Benchetrit committed
48 49
      ],
    },
邓晓峰's avatar
邓晓峰 committed
50 51 52
    development: {
      plugins: ['react-refresh/babel']
    },
Julien Benchetrit's avatar
Julien Benchetrit committed
53
    test: {
邓晓峰's avatar
邓晓峰 committed
54
      plugins: ['@babel/plugin-transform-modules-commonjs', 'dynamic-import-node']
Julien Benchetrit's avatar
Julien Benchetrit committed
55 56 57
    },
  },
};