forked from soederpop/poker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.babel-preset.js
85 lines (80 loc) · 1.88 KB
/
.babel-preset.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
73
74
75
76
77
78
79
80
81
82
83
84
85
const { REQUIRE_CONTEXT_HOOK, NODE_ENV, BUILD_ENV = NODE_ENV } = process.env
const isESBuild = BUILD_ENV === 'build-es'
const isUMDBuild = BUILD_ENV === 'build-umd'
const isWebBuild = BUILD_ENV === 'build-web'
const isLibBuild = BUILD_ENV === 'build' || isESBuild || isUMDBuild || NODE_ENV === 'test'
const isDocsBuild = NODE_ENV === 'development' || NODE_ENV === 'production'
const browsers = [
'last 8 versions',
'safari > 8',
'firefox > 23',
'chrome > 24',
'opera > 15',
'not ie < 11',
'not ie_mob <= 11',
]
const plugins = [
'babel-plugin-require-context-hook',
['@babel/plugin-proposal-decorators', { legacy: true }],
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-export-namespace-from',
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-object-rest-spread',
[
'@babel/plugin-transform-runtime',
{
regenerator: isDocsBuild,
},
],
/*
// Plugins that allow to reduce the target bundle size
'lodash',
'transform-react-handled-props',
[
'transform-react-remove-prop-types',
{
mode: isUMDBuild ? 'remove' : 'wrap',
removeImport: isUMDBuild,
},
],
// A plugin for react-static
isDocsBuild && [
'universal-import',
{
disableWarnings: true,
},
],
// A plugin for removal of debug in production builds
isLibBuild && [
'filter-imports',
{
imports: {
'./makeDebugger': ['default'],
'../../lib': ['makeDebugger'],
},
},
],
*/
].filter(Boolean)
module.exports = () => ({
compact: false,
presets: [
[
'@babel/env',
{
modules: isESBuild || isUMDBuild ? false : 'commonjs',
targets: {
...(isLibBuild && { node: '8.0.0' }),
browsers,
},
},
],
'@babel/react',
],
plugins,
env: {
development: {
plugins: ['react-hot-loader/babel'],
},
}
})