forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
60 lines (55 loc) · 1.84 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
const bpmr = require('babel-plugin-module-resolver');
const fse = require('fs-extra');
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 = {
'@material-ui/core': '../packages/material-ui/src',
'@material-ui/docs': '../packages/material-ui-docs/src',
'@material-ui/icons': '../packages/material-ui-icons/src',
'@material-ui/lab': '../packages/material-ui-lab/src',
'@material-ui/styles': '../packages/material-ui-styles/src',
'@material-ui/system': '../packages/material-ui-system/src',
'@material-ui/utils': '../packages/material-ui-utils/src',
docs: './',
modules: '../modules',
pages: './pages',
};
const { version: transformRuntimeVersion } = fse.readJSONSync(
require.resolve('@babel/runtime-corejs2/package.json'),
);
module.exports = {
presets: [
// backport of https://github.com/zeit/next.js/pull/9511
['next/babel', { 'transform-runtime': { corejs: 2, version: transformRuntimeVersion } }],
],
plugins: [
'babel-plugin-optimize-clsx',
// for IE 11 support
'@babel/plugin-transform-object-assign',
'babel-plugin-preval',
[
'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-transform-dev-warning',
['babel-plugin-react-remove-properties', { properties: ['data-mui-test'] }],
['babel-plugin-transform-react-remove-prop-types', { mode: 'remove' }],
],
},
},
};