-
Notifications
You must be signed in to change notification settings - Fork 9
/
babel.config.js
36 lines (33 loc) · 953 Bytes
/
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
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-env',
{
useBuiltIns: web ? 'usage' : undefined,
corejs: web ? 3 : false,
targets: !web ? { node: 'current' } : undefined,
modules: webpack ? false : 'commonjs',
},
],
'@babel/preset-react',
'@babel/preset-typescript',
],
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-private-methods',
],
sourceType: 'unambiguous',
};
};