-
Notifications
You must be signed in to change notification settings - Fork 201
/
babel.config.js
56 lines (53 loc) · 1.63 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
53
54
55
56
module.exports = (api) => {
api.cache.using(() => process.env.NODE_ENV);
const isTargetWeb = api.caller((caller) => caller && caller.target === 'web');
const isDev = ['test', 'production'].includes(process.env.NODE_ENV) === false;
return {
compact: true,
presets: [
[
'@babel/env',
{
modules: false,
useBuiltIns: 'entry',
corejs: 3.6,
...(isTargetWeb === false && {
targets: {
node: 'current',
},
}),
},
],
'@babel/react',
'@babel/typescript',
],
plugins: [
'@babel/proposal-object-rest-spread',
'@babel/proposal-class-properties',
'@babel/proposal-optional-chaining',
'@babel/syntax-dynamic-import',
'macros',
isDev && isTargetWeb && 'react-refresh/babel',
].filter(Boolean),
env: {
test: {
plugins: [
'@babel/transform-modules-commonjs',
'@babel/syntax-dynamic-import',
'@babel/plugin-transform-runtime',
],
},
tooling: {
presets: [
[
'@babel/env',
{
modules: 'commonjs',
},
],
'@babel/typescript',
],
},
},
};
};