This repository has been archived by the owner on Jan 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
72 lines (62 loc) · 1.87 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
var env = require('@babel/preset-env');
var react = require('@babel/preset-react');
var flow = require('@babel/preset-flow');
var transformRuntime = require('@babel/plugin-transform-runtime');
var transformClassProperties = require('@babel/plugin-proposal-class-properties');
var syntaxDynamicImport = require('@babel/plugin-syntax-dynamic-import');
module.exports = function(context, options) {
options = options || {};
var disabled = options.disabled || [];
var browser = options.browser || false;
var config = options.config || {};
var presets = [];
var plugins = [];
// @babel/preset-env
if(disabled.indexOf('env') === -1) {
presets.push([
env,
Object.assign({
targets: browser ? {browsers: 'last 2 versions'} : {node: 'current'}
}, config.env)
])
}
// @babel/preset-react
if(disabled.indexOf('react') === -1) {
presets.push([
react,
config.react
]);
}
// @babel/preset-flow
if(disabled.indexOf('flow') === -1) {
presets.push([
flow,
config.flow
]);
}
// @babel/plugin-transform-runtime
if(disabled.indexOf('transform-runtime') === -1) {
plugins.push([
transformRuntime,
config['transform-runtime']
]);
}
// @babel/plugin-proposal-class-properties
if(disabled.indexOf('transform-class-properties') === -1) {
plugins.push([
transformClassProperties,
config['transform-class-properties']
]);
}
// @babel/plugin-syntax-dynamic-import
if(disabled.indexOf('syntax-dynamic-import') === -1) {
plugins.push([
syntaxDynamicImport,
config['syntax-dynamic-import']
]);
}
return {
presets: presets,
plugins: plugins
};
}