-
Notifications
You must be signed in to change notification settings - Fork 8
/
.babelrc.js
44 lines (41 loc) · 1.01 KB
/
.babelrc.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
/**
*
* @param {import('@babel/core').ConfigAPI} api
* @returns
*/
module.exports = api => {
const BABEL_ENV = api.env()
let targets = {}
if (BABEL_ENV === 'test') {
targets = { node: 'current' }
} else if (BABEL_ENV === 'development') {
targets =
'last 1 chrome version, last 1 firefox version, last 1 safari version'
} else if (BABEL_ENV === 'production') {
targets = 'last 1 chrome version, last 1 firefox version, last 1 safari version'
}
/**
* @type {import('@babel/core').TransformOptions}
*/
const babelConfig = {
presets: [
['@babel/env', { targets }],
['@babel/react', { runtime: 'automatic' }],
'@babel/preset-typescript',
],
plugins: [
[
'macros',
{
styledComponents: {
pure: true,
displayName: true,
},
},
],
'@babel/plugin-proposal-class-properties',
BABEL_ENV === 'development' && 'react-refresh/babel',
].filter(Boolean),
}
return babelConfig
}