-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
52 lines (45 loc) · 1.5 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
const envPreset = require('@babel/preset-env');
const reactPreset = require('@babel/preset-react');
const syntaxDynamicImport = require('@babel/plugin-syntax-dynamic-import').default;
const transformRuntime = require('@babel/plugin-transform-runtime').default;
const proposalClassProperties = require('@babel/plugin-proposal-class-properties').default;
const exportDefaultFrom = require('@babel/plugin-proposal-export-default-from').default;
const proposalOptionalChaining = require('@babel/plugin-proposal-optional-chaining').default;
const removePropTypes = require('babel-plugin-transform-react-remove-prop-types').default;
const { browserList, legacyBrowserList } = require('./browserlist');
module.exports = (api = {}, opts = {}) => {
const serverOnly = opts.serverOnly || (api.env && api.env('server'));
const isModern = opts.modern || (api.env && api.env('modern'));
const targets = {
node: 'current',
};
if (!serverOnly) {
targets.browsers = isModern ? browserList : legacyBrowserList;
}
const presetEnvOptions = Object.assign(
{},
{ targets },
opts['preset-env']
);
const reactPresetOptions = Object.assign({}, opts['react-preset']);
return {
presets: [
[
envPreset,
presetEnvOptions,
],
[
reactPreset,
reactPresetOptions,
],
],
plugins: [
syntaxDynamicImport,
transformRuntime,
proposalClassProperties,
exportDefaultFrom,
proposalOptionalChaining,
removePropTypes,
],
};
};