forked from gregberge/loadable-components
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbabel.config.js
More file actions
32 lines (29 loc) · 797 Bytes
/
babel.config.js
File metadata and controls
32 lines (29 loc) · 797 Bytes
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
function isWebTarget(caller) {
return Boolean(caller && caller.target === 'web')
}
function isWebpack(caller) {
return Boolean(caller && caller.name === 'babel-loader')
}
module.exports = api => {
const web = api.caller(isWebTarget)
const webpack = api.caller(isWebpack)
return {
presets: [
'@babel/preset-react',
[
'@babel/preset-env',
{
useBuiltIns: web ? 'entry' : undefined,
corejs: web ? 'core-js@3' : false,
targets: !web ? { node: 'current' } : undefined,
modules: webpack ? false : 'commonjs',
},
],
],
plugins: ['@babel/plugin-syntax-dynamic-import', '@loadable/babel-plugin',
/* ["transform-define", {
"process.env.NODE_ENV": process.env.NODE_ENV,
}] */
],
}
}