1 | const babelConfigForWebpackBuild = {
|
2 | presets: [
|
3 | [
|
4 | '@babel/preset-env',
|
5 | {
|
6 | loose: true,
|
7 | useBuiltIns: 'entry',
|
8 | corejs: 2,
|
9 | },
|
10 | ],
|
11 | '@babel/preset-react',
|
12 | ],
|
13 | plugins: [
|
14 | '@babel/plugin-syntax-dynamic-import',
|
15 | '@babel/plugin-syntax-import-meta',
|
16 | '@babel/plugin-proposal-class-properties',
|
17 | '@babel/plugin-proposal-json-strings',
|
18 | '@babel/plugin-transform-react-constant-elements',
|
19 | ],
|
20 | };
|
21 |
|
22 | const babelConfigForJest = {
|
23 | presets: [
|
24 | [
|
25 | '@babel/preset-env',
|
26 | {
|
27 | loose: true,
|
28 | useBuiltIns: 'entry',
|
29 | corejs: 2,
|
30 | targets: {
|
31 | node: 'current',
|
32 | },
|
33 | },
|
34 | ],
|
35 | '@babel/preset-react',
|
36 | ],
|
37 | plugins: [
|
38 | '@babel/plugin-syntax-dynamic-import',
|
39 | '@babel/plugin-syntax-import-meta',
|
40 | '@babel/plugin-proposal-class-properties',
|
41 | '@babel/plugin-proposal-json-strings',
|
42 | '@babel/plugin-transform-react-constant-elements',
|
43 | ],
|
44 | };
|
45 |
|
46 | module.exports = api => {
|
47 | const isTest = api.env('test');
|
48 |
|
49 | if (isTest) {
|
50 | return babelConfigForJest;
|
51 | }
|
52 |
|
53 | return babelConfigForWebpackBuild;
|
54 | };
|