-
Notifications
You must be signed in to change notification settings - Fork 2
/
babel.config.js
52 lines (50 loc) · 1.71 KB
/
babel.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* eslint-disable import/no-dynamic-require, global-require, @typescript-eslint/no-var-requires, camelcase */
module.exports = (api) => {
const isProd = api.env('production');
const { minimum_chrome_version } = require(`./src/manifest.${isProd ? 'prod' : 'dev'}.json`);
const envPreset = [
'@babel/env',
{
modules: false,
targets: minimum_chrome_version
? `Chrome > ${minimum_chrome_version}`
: 'last 2 Chrome versions',
useBuiltIns: 'usage',
corejs: 3,
},
];
const importPlugin = [
'import',
{
libraryName: 'antd',
libraryDirectory: 'es',
style: true,
},
];
return {
presets: ['@babel/preset-typescript', envPreset],
plugins: [
'@babel/plugin-transform-runtime',
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-optional-chaining',
['@babel/plugin-proposal-class-properties', { loose: false }],
['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true }],
'lodash',
importPlugin,
],
env: {
development: {
presets: [['@babel/preset-react', { development: true }]],
plugins: ['react-hot-loader/babel'],
},
production: {
presets: ['@babel/preset-react'],
plugins: [
'babel-plugin-dev-expression',
'@babel/plugin-transform-react-constant-elements',
'@babel/plugin-transform-react-inline-elements',
],
},
},
};
};