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 | "@babel/env",
|
13 | "@babel/preset-react"
|
14 | ];
|
15 | const plugins = [
|
16 | ["@babel/plugin-proposal-decorators", { legacy: true }],
|
17 | "@babel/plugin-proposal-class-properties",
|
18 | "babel-plugin-styled-components",
|
19 | "babel-plugin-syntax-dynamic-import"
|
20 | ];
|
21 | if (api.env("development")) {
|
22 | if (process.env.BABEL_EXTENSION_PATH && !process.env.BABEL_EXTENSION_PATH.includes(__dirname)) {
|
23 | utils.verbose("Not using react-hot-loader/babel plugin with auspice extensions as this produces an error. TO FIX.");
|
24 | |
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | } else {
|
33 | plugins.push("react-hot-loader/babel");
|
34 | }
|
35 | }
|
36 | if (process.env.BABEL_INCLUDE_TIMING_FUNCTIONS === "false") {
|
37 | plugins.push(["strip-function-call", {strip: ["timerStart", "timerEnd"]}]);
|
38 | }
|
39 | api.cache(true);
|
40 | return {
|
41 | presets,
|
42 | plugins
|
43 | };
|
44 | };
|