-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbabel.config.js
76 lines (73 loc) · 1.86 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const plugins = [
"@babel/plugin-transform-runtime",
// @see https://mui.com/guides/minimizing-bundle-size/
[
"babel-plugin-import",
{
libraryName: "@mui/material",
libraryDirectory: "",
camel2DashComponentName: false,
},
"core",
],
[
"babel-plugin-import",
{
libraryName: "@mui/icons-material",
libraryDirectory: "",
camel2DashComponentName: false,
},
"icons",
],
// @see https://github.com/ant-design/babel-plugin-import
[
"babel-plugin-import",
{
libraryName: "lodash",
libraryDirectory: "",
camel2DashComponentName: false, // default: true
},
],
];
// We need babel for code instrumentation
const enableCoverage = process.env.COVERAGE && process.env.COVERAGE !== "false";
if (enableCoverage) {
const debug = require("debug")("coverage");
debug("Enabling istanbul plugin in babel"); // eslint-disable-line no-console
plugins.push("istanbul");
}
// Add support of styled components
// plugins.push([
// "styled-components",
// {
// ssr: true,
// displayName: true,
// preprocess: false,
// },
// ]);
module.exports = {
// we also need next/babel preset to work with Next
presets: [
"@babel/preset-env",
"@babel/preset-typescript",
"@babel/preset-react", // TODO: this should be moved up into packages, because not all of them are actually using React
//[
//
//"next/babel", // next/babel is not available as an independant package yet
//{
// "styled-jsx": {
// plugins: ["styled-jsx-plugin-postcss"],
// },
//},
//],
],
plugins,
babelrc: false,
env: {
// @see https://babeljs.io/docs/en/babel-plugin-transform-modules-commonjs
// @see https://bl.ocks.org/rstacruz/511f43265de4939f6ca729a3df7b001c
test: {
plugins: ["@babel/plugin-transform-modules-commonjs"],
},
},
};