-
Notifications
You must be signed in to change notification settings - Fork 21
/
babel.config.js
42 lines (39 loc) · 1.23 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
module.exports = function createConfig(api) {
const config = {
plugins: [
[require.resolve('@babel/plugin-proposal-class-properties')],
[require.resolve('@babel/plugin-proposal-export-default-from')],
[require.resolve('@babel/plugin-proposal-export-namespace-from')],
[require.resolve('@babel/plugin-proposal-nullish-coalescing-operator')],
[require.resolve('@babel/plugin-proposal-object-rest-spread')],
[require.resolve('@babel/plugin-proposal-optional-chaining')],
[require.resolve('@babel/plugin-syntax-dynamic-import')],
[require.resolve('@babel/plugin-proposal-private-methods')],
],
presets: [],
};
if (api.env('test')) {
config.plugins.push([require.resolve('babel-plugin-dynamic-import-node')]);
config.presets.push([
require.resolve('@babel/preset-env'),
{
targets: {
node: 'current',
},
},
]);
} else {
config.presets.push([
require.resolve('@babel/preset-env'),
{
corejs: {
proposals: true,
version: 3,
},
useBuiltIns: 'usage',
},
]);
}
config.presets.push([require.resolve('@babel/preset-react'), { runtime: 'automatic' }]);
return config;
};