forked from twreporter/twreporter-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-babel-preset.js
58 lines (54 loc) · 1.06 KB
/
build-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
'use strict'
const isProduction = process.env.NODE_ENV === 'production'
const isServeSideRendering = process.env.RENDER_ENV === 'server'
const presets = [
[
'@babel/preset-env',
{
targets: {
node: 'current',
browsers: ['last 2 versions'],
},
debug: isProduction,
useBuiltIns: 'usage',
corejs: {
version: 3,
proposals: true,
},
},
],
require('@babel/preset-react'),
]
const plugins = [
isServeSideRendering
? 'dynamic-import-node-babel-7'
: '@babel/plugin-syntax-dynamic-import',
[
'babel-plugin-styled-components',
{
ssr: true,
displayName: !isProduction,
},
],
'babel-plugin-inline-import-data-uri',
[
'babel-plugin-inline-react-svg',
{
svgo: {
plugins: [
{
cleanupIDs: false,
},
],
},
},
],
'@babel/plugin-transform-runtime',
'@loadable/babel-plugin',
].filter(Boolean)
module.exports = function buildTwreporterReactPreset() {
return {
presets,
plugins,
}
}