forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbabel.config.js
87 lines (81 loc) · 2.58 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
77
78
79
80
81
82
83
84
85
86
87
const bpmr = require('babel-plugin-module-resolver');
const fse = require('fs-extra');
const path = require('path');
const errorCodesPath = path.resolve(__dirname, './public/static/error-codes.json');
function resolvePath(sourcePath, currentFile, opts) {
if (sourcePath === 'markdown') {
const base = currentFile.substring(__dirname.length).slice(0, -3);
return `${__dirname}/docs/src/${base}/`;
}
return bpmr.resolvePath(sourcePath, currentFile, opts);
}
const alias = {
'@mui/material': '../packages/mui-material/src',
'@mui/docs': '../packages/mui-docs/src',
'@mui/icons-material': '../packages/mui-icons-material/lib',
'@mui/lab': '../packages/mui-lab/src',
'@mui/styles': '../packages/mui-styles/src',
'@mui/styled-engine-sc': '../packages/mui-styled-engine-sc/src',
// Swap the comments on the next two lines for using the styled-components as style engine
'@mui/styled-engine': '../packages/mui-styled-engine/src',
// '@mui/styled-engine': '../packages/mui-styled-engine-sc/src',
'@mui/system': '../packages/mui-system/src',
'@mui/private-theming': '../packages/mui-private-theming/src',
'@mui/utils': '../packages/mui-utils/src',
'@mui/base': '../packages/mui-base/src',
'@mui/material-next': '../packages/mui-material-next/src',
'@mui/joy': '../packages/mui-joy/src',
docs: './',
modules: '../modules',
pages: './pages',
};
const { version: transformRuntimeVersion } = fse.readJSONSync(
require.resolve('@babel/runtime-corejs2/package.json'),
);
module.exports = {
// TODO: Enable once nextjs uses babel 7.13
// assumptions: {
// noDocumentAll: true,
// },
presets: [
// backport of https://github.com/vercel/next.js/pull/9511
[
'next/babel',
{
'preset-react': { runtime: 'automatic' },
'transform-runtime': { corejs: 2, version: transformRuntimeVersion },
},
],
],
plugins: [
[
'babel-plugin-macros',
{
muiError: {
errorCodesPath,
},
},
],
'babel-plugin-optimize-clsx',
// for IE11 support
'@babel/plugin-transform-object-assign',
[
'babel-plugin-module-resolver',
{
alias,
transformFunctions: ['require', 'require.context'],
resolvePath,
},
],
],
ignore: [/@babel[\\|/]runtime/], // Fix a Windows issue.
env: {
production: {
plugins: [
'@babel/plugin-transform-react-constant-elements',
['babel-plugin-react-remove-properties', { properties: ['data-mui-test'] }],
['babel-plugin-transform-react-remove-prop-types', { mode: 'remove' }],
],
},
},
};