-
Notifications
You must be signed in to change notification settings - Fork 5
/
rollup.config.js
76 lines (70 loc) · 1.58 KB
/
rollup.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import babel from 'rollup-plugin-babel'
import commonjs from 'rollup-plugin-commonjs'
import replace from 'rollup-plugin-replace'
import resolve from 'rollup-plugin-node-resolve'
import uglify from 'rollup-plugin-uglify'
const { BUILD_ENV, BUILD_FORMAT } = process.env
const babelPlugins = [
'transform-object-rest-spread',
'transform-class-properties',
]
if (BUILD_ENV === 'production') {
babelPlugins.push([
'transform-react-remove-prop-types',
{ removeImport: true },
])
}
const config = {
input: 'modules/index.js',
output: {
name: 'ReactGoogleApi',
globals: {
react: 'React',
},
},
// by listing no external, everything is external, we just get a warning
// external: [],
plugins: [
babel({
babelrc: false,
presets: [
'react',
[
'env',
{
loose: true,
modules: false,
targets: {
chrome: '60',
edge: '15',
firefox: '57',
ios: '10.3',
},
},
],
],
plugins: babelPlugins,
exclude: 'node_modules/**',
}),
],
}
if (BUILD_FORMAT === 'umd') {
config.plugins.push(
...[
resolve(),
commonjs({
include: /node_modules/,
}),
replace({
'process.env.NODE_ENV': JSON.stringify(BUILD_ENV),
}),
],
)
if (BUILD_ENV === 'production') {
config.plugins.push(uglify())
}
// In the browser build, include our smaller dependencies
// so users only need to include React
config.external = ['react']
}
export default config