-
Notifications
You must be signed in to change notification settings - Fork 10.3k
/
index.js
51 lines (45 loc) · 1.22 KB
/
index.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
const r = require(`./resolver`)
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`],
},
}
const nodeConfig = {
targets: {
node: PRODUCTION ? 6.0 : `current`,
},
}
return {
presets: [
[
r(`@babel/preset-env`),
Object.assign(
{
loose: true,
debug: !!debug,
useBuiltIns: `entry`,
shippedProposals: true,
modules: `commonjs`,
},
browser ? browserConfig : nodeConfig
),
],
[r(`@babel/preset-react`), { development: !PRODUCTION }],
r(`@babel/preset-flow`),
],
plugins: [
r(`@babel/plugin-proposal-class-properties`),
r(`@babel/plugin-proposal-optional-chaining`),
r(`@babel/plugin-transform-runtime`),
r(`@babel/plugin-syntax-dynamic-import`),
],
}
}
module.exports = preset