forked from stormid/frontend-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
52 lines (47 loc) · 2.14 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
module.exports = function (api) {
// Cache the returned value forever and don't call this function again.
api.cache(true);
// Don't cache at all. Not recommended because it will be very slow.
//api.cache(false);
// Cached based on the value of some function. If this function returns a value different from
// a previously-encountered value, the plugins will re-evaluate.
//var env = api.cache(() => process.env.NODE_ENV);
// If testing for a specific env, we recommend specifics to avoid instantiating a plugin for
// any possible NODE_ENV value that might come up during plugin execution.
//var isProd = api.cache(() => process.env.NODE_ENV === "production");
// .cache(fn) will perform a linear search though instances to find the matching plugin based
// based on previous instantiated plugins. If you want to recreate the plugin and discard the
// previous instance whenever something changes, you may use:
//var isProd = api.cache.invalidate(() => process.env.NODE_ENV === "production");
// Note, we also expose the following more-verbose versions of the above examples:
//api.cache.forever(); // api.cache(true)
//api.cache.never(); // api.cache(false)
//api.cache.using(fn); // api.cache(fn)
return {
presets: [
[
'@babel/preset-env',
Object.assign({}, process.env.NODE_ENV === 'test'
? {
targets: {
node: 12,
}
}
: {
modules: false,
exclude: ['transform-regenerator', 'transform-async-to-generator'],
}
)
]
],
plugins: [
['@babel/plugin-transform-react-jsx', {
pragma: 'h'
}],
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-transform-object-assign',
'@babel/plugin-proposal-object-rest-spread',
['module:fast-async', { spec: true }]
]
};
};