-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
41 lines (36 loc) · 990 Bytes
/
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
const env = api => {
const conf = {
targets: {},
...(!api.env('test') && {
loose: true,
}),
};
switch (api.env()) {
case 'development':
conf.targets.node = 'current';
break;
case 'es6':
conf.targets.chrome = 52;
break;
default:
conf.targets.ie = 10;
break;
}
return ['@babel/preset-env', conf];
};
module.exports = api => {
const presets = [env(api)];
const plugins = [
'babel-plugin-add-module-exports',
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-nullish-coalescing-operator',
['@babel/plugin-proposal-pipeline-operator', { proposal: 'minimal' }],
api.env('production') && '@babel/plugin-transform-object-assign',
api.env('test') && '@babel/plugin-transform-runtime',
].filter(Boolean);
return {
include: [/src/, /testUtils/, /node_modules/],
presets,
plugins,
};
};