-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
65 lines (53 loc) · 1.76 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
53
54
55
56
57
58
59
60
61
62
63
64
65
'use strict'
const env = process.env.BABEL_ENV || process.env.NODE_ENV || 'development'
// require.resolve('@babel/register')
const preset23 = () => ({
comments: true,
presets: [
[
require.resolve('@babel/preset-env', {
modules: 'auto',
'targets': { browsers: ['> 1%', 'last 2 versions', 'not ie <= 8'] }
})
],
require.resolve('@babel/preset-react')
],
plugins: [
require.resolve('@babel/plugin-transform-runtime'),
[require.resolve('@babel/plugin-proposal-decorators'), { 'legacy': true }],
require.resolve('@babel/plugin-proposal-class-properties', { 'loose' : true }),
require.resolve('@babel/plugin-transform-react-constant-elements'),
require.resolve('@babel/plugin-proposal-export-default-from'),
// Adds support for import()
// require.resolve('@babel/plugin-syntax-dynamic-import'), // clientside import()
require.resolve('babel-plugin-dynamic-import-node') // serverSide import() for SSR
]
})
module.exports = preset23
/*
TODOS:
+ dev / prod
+ some other conditional plugins/presets
+ dynamic import use latest method
let env = process.env.BABEL_ENV || process.env.NODE_ENV || 'development'
// TBD: check process args for --production param
if (env === 'development' || env === 'test') {
// Adds component stack to warning messages
preset23.plugins.push(
require.resolve('@babel/plugin-transform-react-jsx-source')
)
}
if (env === 'test') {
// preset23.plugins.push(
// TBD
// )
}
if (env === 'production') {
preset23.plugins.push(
require.resolve('babel-plugin-transform-react-remove-prop-types')
)
}
module.exports = function() {
return preset23
}
*/