-
Notifications
You must be signed in to change notification settings - Fork 163
/
babel.config.js
41 lines (39 loc) · 1.18 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
const utils = require('./cli/utils');
/* What variables does this config depend on?
* process.env.BABEL_EXTENSION_PATH -- a resolved path
* api.env -- this is process.env.BABEL_ENV if it exists (it should)
* process.env.BABEL_INCLUDE_TIMING_FUNCTIONS
*/
module.exports = function babelConfig(api) {
utils.verbose(`Generating Babel Config`);
const presets = [
[
"@babel/preset-env",
{
useBuiltIns: false, // use the full lib to make sure vendor bundle stays stable
targets: !api.env('test') ? "cover 95%" : { node: 'current' },
bugfixes: true
}
],
"@babel/preset-react",
"@babel/preset-typescript"
];
const plugins = [
["@babel/plugin-proposal-decorators", { legacy: true }],
"@babel/plugin-proposal-class-properties",
"babel-plugin-styled-components",
"@babel/plugin-syntax-dynamic-import",
"lodash"
];
if (api.env("development")) {
plugins.push(["react-hot-loader/babel", { safetyNet: false }]);
}
if (process.env.BABEL_INCLUDE_TIMING_FUNCTIONS === "false") {
plugins.push(["strip-function-call", {strip: ["timerStart", "timerEnd"]}]);
}
api.cache(true);
return {
presets,
plugins
};
};