UNPKG

1.16 kBJavaScriptView Raw
1const utils = require('./cli/utils');
2
3/* What variables does this config depend on?
4 * process.env.BABEL_EXTENSION_PATH -- a resolved path
5 * api.env -- this is process.env.BABEL_ENV if it exists (it should)
6 * process.env.BABEL_INCLUDE_TIMING_FUNCTIONS
7 */
8
9module.exports = function babelConfig(api) {
10 utils.verbose(`Generating Babel Config`);
11 const presets = [
12 [
13 "@babel/preset-env",
14 {
15 useBuiltIns: false, // use the full lib to make sure vendor bundle stays stable
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};