1 | const utils = require('./cli/utils');
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | module.exports = function babelConfig(api) {
|
10 | utils.verbose(`Generating Babel Config`);
|
11 | const presets = [
|
12 | [
|
13 | "@babel/preset-env",
|
14 | {
|
15 | useBuiltIns: false,
|
16 | targets: !api.env('test') ? "cover 95%" : { node: 'current' },
|
17 | bugfixes: true
|
18 | }
|
19 | ],
|
20 | "@babel/preset-react"
|
21 | ];
|
22 | const plugins = [
|
23 | ["@babel/plugin-proposal-decorators", { legacy: true }],
|
24 | "@babel/plugin-proposal-class-properties",
|
25 | "babel-plugin-styled-components",
|
26 | "@babel/plugin-syntax-dynamic-import",
|
27 | "lodash"
|
28 | ];
|
29 | if (api.env("development")) {
|
30 | plugins.push("react-hot-loader/babel");
|
31 | }
|
32 | if (process.env.BABEL_INCLUDE_TIMING_FUNCTIONS === "false") {
|
33 | plugins.push(["strip-function-call", {strip: ["timerStart", "timerEnd"]}]);
|
34 | }
|
35 | api.cache(true);
|
36 | return {
|
37 | presets,
|
38 | plugins
|
39 | };
|
40 | };
|