forked from DylanJu/react-pure-ssr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbabel.config.js
More file actions
47 lines (44 loc) · 1.13 KB
/
babel.config.js
File metadata and controls
47 lines (44 loc) · 1.13 KB
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
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,
targets: !web ? { node: 'current' } : undefined,
modules: webpack ? false : 'commonjs',
},
],
'@babel/preset-typescript',
],
plugins: [
'@loadable/babel-plugin',
[
'module-resolver',
{
root: ['.'],
extensions: ['.ts', '.tsx'],
alias: {
'@src': './src',
'@components': './src/components',
'@pages': './src/components/pages',
'@store': './src/store',
'@reducers': './src/store/reducers',
'@actions': './src/store/actions',
'@util': './src/util',
'@styles': './src/styles',
},
},
],
],
};
};