-
Notifications
You must be signed in to change notification settings - Fork 1
/
babel.config.js
64 lines (62 loc) · 1.68 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
57
58
59
60
61
62
63
64
module.exports = api => {
const env = api.env()
const isServerDev = env === 'development_server'
const isServerProd = env === 'production_server'
const isClientDev = env === 'development_client'
const isClientProd = env === 'production_client'
const isTest = env === 'test'
api.cache.using(() => isTest || isClientDev || isServerDev)
return {
presets: [
isTest && [
'@babel/preset-env',
{
targets: {
node: 'current'
}
}
],
(isServerDev || isServerProd) && [
'@babel/preset-env',
{
targets: {
node: 'current'
},
modules: false
}
],
isClientDev && [
'@babel/preset-env',
{
targets: {
browsers: 'last 2 Chrome versions'
},
modules: false
}
],
isClientProd && [
'@babel/preset-env',
{
targets: {
browsers: '>1%, not dead, not ie 11, not op_mini all'
},
loose: true,
modules: false,
useBuiltIns: 'usage',
corejs: 3,
shippedProposals: true
}
],
'@babel/preset-typescript',
'@babel/preset-react'
].filter(Boolean),
plugins: [
(isClientDev || isClientProd) && '@babel/plugin-syntax-dynamic-import',
(isServerDev || isServerProd || isTest) &&
'babel-plugin-dynamic-import-node',
['@babel/plugin-proposal-class-properties', { loose: true }],
['@babel/plugin-proposal-nullish-coalescing-operator', { loose: true }],
['@babel/plugin-proposal-optional-chaining', { loose: true }]
].filter(Boolean)
}
}