-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
50 lines (46 loc) · 1.1 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
// See https://babeljs.io/docs/en/config-files#root-babelconfigjs-files
module.exports = function getBabelConfig(api) {
const isTest = api.env('test');
// Config for when running Jest tests
if (isTest) {
return {
plugins: [
'@babel/plugin-proposal-class-properties',
],
presets: [
'@babel/env',
'@babel/preset-react',
],
};
}
// We set this in the `build:modules` package.json script
const esmodules = process.env.BABEL_MODULES === '1';
const babelEnvOptions = {
modules: esmodules ? false : 'auto',
// https://babeljs.io/docs/en/babel-preset-env#targets
targets: {
// 'browsers' target is ignored when 'esmodules' is true
esmodules,
},
};
return {
ignore: [
'**/*.test.js',
'__snapshots__',
],
plugins: [
'@babel/plugin-proposal-class-properties',
[
'@babel/plugin-transform-runtime',
{
useESModules: esmodules,
},
],
],
presets: [
['@babel/env', babelEnvOptions],
'@babel/preset-react',
],
sourceMaps: true,
};
};