forked from gaearon/react-side-effect
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrollup.config.js
49 lines (44 loc) · 1.12 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
import babel from 'rollup-plugin-babel'
import uglify from 'rollup-plugin-uglify'
import resolve from 'rollup-plugin-node-resolve'
const { BUILD_ENV, BUILD_FORMAT } = process.env
const config = {
input: 'src/index.js',
output: {
name: 'withSideEffect',
globals: {
react: 'React',
},
},
plugins: [
babel({
runtimeHelpers: true,
babelrc: false,
presets: [
'@babel/preset-react',
['@babel/preset-env', { loose: true, modules: false }]
],
plugins: [
['@babel/plugin-transform-runtime', {
useESModules: BUILD_FORMAT === 'es' || BUILD_FORMAT === 'umd'
}],
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-class-properties'
],
exclude: 'node_modules/**',
}),
],
external: ['react', 'exenv'],
}
if (BUILD_FORMAT === 'umd') {
// In the browser build, include our smaller dependencies
// so users only need to include React
config.external = ['react']
config.plugins.push(
resolve(),
)
}
if (BUILD_ENV === 'production') {
config.plugins.push(uglify())
}
export default config