-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.babelrc.js
45 lines (37 loc) · 1.18 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
45
const env = process.env.NODE_ENV;
const isTest = env === 'test'; // used for testing lib src
const isDevelopment = env === 'development'; // used for running docs app
const isProduction = env === 'production'; // used for build docs app and compile lib src
if (!isTest && !isDevelopment && !isProduction) {
throw new Error(
`Invalid NODE_ENV "${env}". Use only from ["test", "development", "production"]`
);
}
const emotionConfig = isProduction
? { hoist: true }
: { sourceMap: true, autoLabel: true };
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: { node: 'current' },
useBuiltIns: 'usage',
modules:
isDevelopment || process.env.MODULE === 'es6' ? false : 'commonjs',
},
],
['@babel/preset-react', { development: !isProduction, useBuiltIns: true }],
'@babel/preset-flow',
],
plugins: [
['babel-plugin-emotion', emotionConfig],
'@babel/plugin-proposal-class-properties',
[
'@babel/plugin-proposal-object-rest-spread',
{ loose: true, useBuiltIns: true },
],
'@babel/plugin-syntax-dynamic-import',
isDevelopment && 'react-hot-loader/babel',
].filter(Boolean),
};