forked from smooth-code/smooth-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
49 lines (44 loc) Β· 1.14 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
const { STYLED_ENGINE = 'styled-components' } = process.env
const getStyledEnginePlugins = () => {
if (process.env.NODE_ENV === 'test') return []
switch (STYLED_ENGINE) {
case 'emotion':
return ['babel-plugin-emotion']
case 'styled-components':
return [['babel-plugin-styled-components', { displayName: false }]]
default:
return []
}
}
let config = {
presets: [
['@babel/preset-env', { loose: true, modules: false }],
'@babel/preset-react',
],
plugins: [
...getStyledEnginePlugins(),
[
'babel-plugin-transform-rename-import',
{
replacements: [
{
original: '(.*)styled-engine$',
replacement: `$1styled-engine/${STYLED_ENGINE}`,
},
],
},
],
'babel-plugin-annotate-pure-calls',
'@babel/plugin-proposal-object-rest-spread',
['@babel/plugin-proposal-class-properties', { loose: true }],
],
}
if (process.env.NODE_ENV === 'test') {
config = Object.assign({}, config, {
plugins: [
...config.plugins,
['@babel/plugin-transform-modules-commonjs', { loose: true }],
],
})
}
module.exports = config