-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
41 lines (36 loc) · 1014 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
// caller.target will be the same as the target option from webpack
// https://webpack.js.org/loaders/babel-loader/#customize-config-based-on-webpack-target
function isWebTarget(caller) {
return Boolean(caller && caller.target === 'web')
}
function isTestBuild(caller) {
return Boolean(caller && caller.name === 'babel-jest')
}
module.exports = (api) => {
const isWeb = api.caller(isWebTarget)
const isTest = api.caller(isTestBuild)
const targets =
isWeb && !isTest
? '> 0.25%, not dead'
: {
node: 'current',
}
/**
* optimize the build process performance by caching config function execution
* result
* @see https://babeljs.io/docs/en/config-files#apicache
*/
api.cache(false) // can not be true, otherwise we cache the server config and use it for the client
return {
presets: [
[
'@babel/preset-env',
{
targets,
},
],
'@babel/preset-react',
'@babel/preset-typescript',
],
}
}