forked from gaearon/react-hot-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
63 lines (57 loc) · 1.67 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
/* eslint-disable flowtype/require-valid-file-annotation, no-console, import/extensions */
import nodeResolve from 'rollup-plugin-node-resolve'
import replace from 'rollup-plugin-replace'
import commonjs from 'rollup-plugin-commonjs'
import babel from 'rollup-plugin-babel'
import json from 'rollup-plugin-json'
import uglify from 'rollup-plugin-uglify'
import pkg from './package.json'
const commonPlugins = [
json(),
nodeResolve(),
babel({plugins: ['external-helpers']}),
commonjs({ignoreGlobal: true}),
]
const getConfig = (input, dist, env) => ({
input,
external: ['react-dom','react', 'fs', 'path'].concat(Object.keys(pkg.dependencies)),
plugins: commonPlugins
.concat(env ? [
replace({
'process.env.NODE_ENV': JSON.stringify(env),
}),
] : [])
.concat(env === 'production' ? [uglify()] : []),
output: [
{
file: dist,
format: 'cjs',
exports: 'named',
globals: {react: 'React'},
},
],
})
export default [
getConfig(
'src/index.dev.js',
'dist/react-hot-loader.development.js',
'development'
),
getConfig(
'src/index.prod.js',
'dist/react-hot-loader.production.min.js',
'production'
),
getConfig('src/babel.dev.js', 'dist/babel.development.js', 'development'),
getConfig('src/babel.prod.js', 'dist/babel.production.min.js', 'production'),
getConfig('src/webpack/index.js', 'dist/webpack.development.js', 'development'),
getConfig('src/webpack/index.js', 'dist/webpack.production.min.js', 'production'),
{
input: 'src/webpack/webpackTagCommonJSExports.js',
plugins: [babel()],
output: {
file: 'dist/webpackTagCommonJSExports.js',
format: 'cjs'
}
}
]