Skip to content

Commit a7a11fc

Browse files
TrySoundtimdorr
authored andcommitted
Bundle umd with rollup (#681)
1 parent f472fba commit a7a11fc

File tree

5 files changed

+178
-395
lines changed

5 files changed

+178
-395
lines changed

.babelrc

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
"plugins": [
3636
"./build/use-lodash-es"
3737
]
38+
},
39+
"rollup": {
40+
"plugins": [
41+
"./build/use-lodash-es",
42+
"external-helpers"
43+
]
3844
}
3945
}
4046
}

package.json

+9-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"scripts": {
99
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --out-dir lib",
1010
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es",
11-
"build:umd": "cross-env BABEL_ENV=commonjs NODE_ENV=development webpack src/index.js dist/react-redux.js",
12-
"build:umd:min": "cross-env BABEL_ENV=commonjs NODE_ENV=production webpack src/index.js dist/react-redux.min.js",
11+
"build:umd": "cross-env BABEL_ENV=rollup NODE_ENV=development rollup -c -o dist/react-redux.js",
12+
"build:umd:min": "cross-env BABEL_ENV=rollup NODE_ENV=production rollup -c -o dist/react-redux.min.js",
1313
"build": "npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:umd:min",
1414
"clean": "rimraf lib dist es coverage",
1515
"lint": "eslint src test",
@@ -50,8 +50,8 @@
5050
"babel-cli": "^6.3.17",
5151
"babel-core": "^6.3.26",
5252
"babel-eslint": "^7.1.1",
53-
"babel-loader": "^6.2.0",
5453
"babel-plugin-check-es2015-constants": "^6.3.13",
54+
"babel-plugin-external-helpers": "^6.22.0",
5555
"babel-plugin-istanbul": "^4.0.0",
5656
"babel-plugin-syntax-jsx": "^6.3.13",
5757
"babel-plugin-transform-decorators-legacy": "^1.2.0",
@@ -92,7 +92,12 @@
9292
"react-dom": "^15.0.0",
9393
"redux": "^3.0.0",
9494
"rimraf": "^2.3.4",
95-
"webpack": "^1.11.0"
95+
"rollup": "^0.41.6",
96+
"rollup-plugin-babel": "^2.7.1",
97+
"rollup-plugin-commonjs": "^8.0.2",
98+
"rollup-plugin-node-resolve": "^3.0.0",
99+
"rollup-plugin-replace": "^1.1.1",
100+
"rollup-plugin-uglify": "^1.0.1"
96101
},
97102
"dependencies": {
98103
"create-react-class": "^15.5.1",

rollup.config.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import nodeResolve from 'rollup-plugin-node-resolve'
2+
import babel from 'rollup-plugin-babel'
3+
import replace from 'rollup-plugin-replace'
4+
import commonjs from 'rollup-plugin-commonjs'
5+
import uglify from 'rollup-plugin-uglify'
6+
7+
const env = process.env.NODE_ENV
8+
9+
const config = {
10+
entry: 'src/index.js',
11+
external: [
12+
'react',
13+
'redux'
14+
],
15+
globals: {
16+
'react': 'React',
17+
'redux': 'Redux'
18+
},
19+
format: 'umd',
20+
moduleName: 'ReactRedux',
21+
plugins: [
22+
nodeResolve(),
23+
babel({
24+
exclude: '**/node_modules/**'
25+
}),
26+
replace({
27+
'process.env.NODE_ENV': JSON.stringify(env)
28+
}),
29+
commonjs()
30+
]
31+
}
32+
33+
if (env === 'production') {
34+
config.plugins.push(
35+
uglify({
36+
compress: {
37+
pure_getters: true,
38+
unsafe: true,
39+
unsafe_comps: true,
40+
screw_ie8: true,
41+
warnings: false
42+
}
43+
})
44+
)
45+
}
46+
47+
export default config

webpack.config.js

-64
This file was deleted.

0 commit comments

Comments
 (0)