-
Notifications
You must be signed in to change notification settings - Fork 1
/
babel.config.js
103 lines (100 loc) · 4 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
const path = require('path');
const getPackagesAliases = require('./scripts/lib/getPackagesAliases');
module.exports = (api) => {
if (api.env('node')) {
return {
ignore: [/node_modules\/(?!@micromag)/],
presets: [
[
require('@babel/preset-env'),
{
targets: {
node: 'current',
},
},
],
[
require('@babel/preset-react'),
{
useBuiltIns: true,
},
],
],
plugins: [
[
require.resolve('babel-plugin-module-resolver'),
{
alias: {
react: require.resolve('react'),
'react-dom/server': require.resolve('react-dom/server'),
'react-dom': require.resolve('react-dom'),
'react-intl': require.resolve('react-intl'),
'react-router': require.resolve('react-router'),
'@react-spring/core': require.resolve('@react-spring/core'),
'@react-spring/web': require.resolve('@react-spring/web'),
'@use-gesture/react': require.resolve('@use-gesture/react'),
...getPackagesAliases({ withoutEndSign: true }),
},
},
],
require.resolve('@babel/plugin-transform-runtime'),
require.resolve('babel-plugin-dynamic-import-node'),
require.resolve('@babel/plugin-proposal-export-namespace-from'),
require.resolve('@babel/plugin-proposal-numeric-separator'),
[
require.resolve('babel-plugin-css-modules-transform'),
{
preprocessCss: path.join(__dirname, './scripts/process-scss.js'),
extensions: ['.scss'],
generateScopedName: path.resolve(
__dirname,
'./scripts/lib/generateScopedName.js',
),
},
],
[
path.join(__dirname, './scripts/babel-plugin-transform-require-ignore'),
{
extensions: ['.global.scss'],
},
],
[
require.resolve('babel-plugin-transform-assets-import-to-string'),
{
extensions: ['.png'],
},
],
],
};
}
console.log('env', api.env('development'));
return {
presets: api.env('development')
? [
'@babel/preset-react',
[
require('@babel/preset-env'),
{
targets: {
node: 'current',
},
},
],
// require.resolve('@babel/plugin-proposal-numeric-separator'),
].filter(Boolean)
: [],
plugins: [
require.resolve('@babel/plugin-proposal-export-namespace-from'),
[
require.resolve('babel-plugin-static-fs'),
{
target: 'browser', // defaults to node
},
],
require.resolve('@babel/plugin-proposal-numeric-separator'),
[require.resolve('@babel/plugin-proposal-private-property-in-object'), { loose: true }],
[require.resolve('@babel/plugin-proposal-class-properties'), { loose: true }],
[require.resolve('@babel/plugin-proposal-private-methods'), { loose: true }],
].filter(Boolean),
};
};