-
Notifications
You must be signed in to change notification settings - Fork 331
/
babel.config.js
50 lines (46 loc) · 1.04 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
const wrapWarningWithDevCheck = require('./scripts/babel/wrap-warning-with-dev-check');
module.exports = (api) => {
const isTest = api.env('test');
const modules = isTest ? 'commonjs' : false;
const targets = {};
if (isTest) {
targets.node = true;
} else {
targets.browsers = ['last 2 versions', 'ie >= 9'];
}
return {
presets: [
'@babel/preset-typescript',
[
'@babel/preset-react',
{ pragma: 'createElement', pragmaFrag: 'Fragment' },
],
[
'@babel/preset-env',
{
modules,
targets,
},
],
],
plugins: clean([
wrapWarningWithDevCheck,
[
'inline-replace-variables',
{
__DEV__: {
type: 'node',
replacement: "process.env.NODE_ENV !== 'production'",
},
__TEST__: {
type: 'node',
replacement: "process.env.NODE_ENV === 'test'",
},
},
],
]),
};
};
function clean(config) {
return config.filter(Boolean);
}