forked from Semantic-Org/Semantic-UI-React
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.babel-preset.js
79 lines (75 loc) · 1.65 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
const { NODE_ENV } = process.env
const isESBuild = NODE_ENV === 'build-es'
const isUMDBuild = NODE_ENV === 'build-umd'
const isLibBuild = NODE_ENV === 'build' || isESBuild || isUMDBuild
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-proposal-class-properties',
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-export-namespace-from',
'@babel/plugin-syntax-dynamic-import',
[
'@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: {
debug: ['default'],
'../../lib': ['makeDebugger'],
},
},
],
].filter(Boolean)
module.exports = () => ({
compact: false,
presets: [
[
'@babel/env',
{
modules: isESBuild || isUMDBuild ? false : 'commonjs',
targets: { browsers },
},
],
'@babel/react',
],
plugins,
env: {
development: {
plugins: ['react-hot-loader/babel'],
},
test: {
plugins: [['istanbul', { include: ['src'] }]],
},
},
})