-
Notifications
You must be signed in to change notification settings - Fork 0
/
.babelrc.js
57 lines (51 loc) · 1.33 KB
/
.babelrc.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
const r = m => require.resolve(m)
function preset(context, options = {}) {
const { browser = false, debug = false } = options
const { NODE_ENV, BABEL_ENV } = process.env
const PRODUCTION = (BABEL_ENV || NODE_ENV) === "production"
const browserConfig = {
useBuiltIns: false,
targets: {
browsers: PRODUCTION
? [`last 4 versions`, `safari >= 7`, "ie >= 9"]
: [`last 2 versions`, `not ie <= 11`, `not android 4.4.3`],
uglify: PRODUCTION,
},
}
const nodeConfig = {
targets: {
node: PRODUCTION ? 4.0 : "current",
},
}
return {
presets: [
[
r("babel-preset-env"),
Object.assign(
{
loose: true,
debug: !!debug,
useBuiltIns: true,
modules: "commonjs",
},
browser ? browserConfig : nodeConfig
),
],
r("babel-preset-react"),
r("babel-preset-flow"),
],
plugins: [
r("babel-plugin-transform-object-rest-spread"),
[
r("babel-plugin-transform-runtime"),
{
// we are only polyfilling the node environment
// so we need to enable the runtime replacements for the browser preset
polyfill: !!browser,
},
],
r(`babel-plugin-transform-flow-strip-types`),
],
}
}
module.exports = preset