-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
78 lines (77 loc) · 2.69 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
const path = require('path');
const getPackagesAliases = require('./scripts/lib/getPackagesAliases');
const getVendorAliases = require('./scripts/lib/getVendorAliases');
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: {
...getVendorAliases(),
...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-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'],
},
],
],
};
}
return {
presets: [api.env('development') && require.resolve('babel-preset-react-app/dev')].filter(
Boolean,
),
plugins: [
require.resolve('@babel/plugin-proposal-export-namespace-from'),
[
require.resolve('babel-plugin-static-fs'),
{
target: 'browser', // defaults to node
},
],
].filter(Boolean),
};
};