-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
57 lines (51 loc) · 1.76 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
module.exports = function (api) {
//handle caching to bust on different node envs
api.cache.using(() => process.env.NODE_ENV)
const isProd = api.env('production')
const isStaging = api.env('staging')
const presets = [
[
"@babel/preset-env",
{
"loose": true,
"useBuiltIns": "usage", // polyfills are matched by target environment
"exclude": ['transform-regenerator', 'transform-async-to-generator'] //because we are using fast-async we exclude the transforms from the preset, else we would need regenerator Runtime and other bloat
}
]
]
let plugins = [
["babel-plugin-inferno", {
"imports": true
}],
"@babel/plugin-transform-modules-commonjs",
"@babel/plugin-syntax-jsx",
["@babel/plugin-proposal-decorators", {
"legacy": true
}],
["@babel/plugin-proposal-class-properties", {
"loose": true
}],
]
if(!isProd && !isStaging ) plugins.push( //will bug the dynamic imports in client bundle. In DEV we load the Server directly and not via a bundle we have to have dynamic import node here
'dynamic-import-node'
)
if (isProd || isStaging) plugins.push(
"@babel/plugin-transform-arrow-functions",
"@babel/plugin-transform-block-scoped-functions",
"@babel/plugin-transform-block-scoping",
"@babel/plugin-transform-classes",
"@babel/plugin-transform-computed-properties",
"@babel/plugin-transform-destructuring",
"@babel/plugin-transform-literals",
"@babel/plugin-transform-parameters",
"@babel/plugin-transform-shorthand-properties",
"@babel/plugin-transform-spread",
"@babel/plugin-transform-template-literals",
"@babel/plugin-proposal-object-rest-spread",
["module:fast-async"]
)
return {
presets,
plugins
}
}