Skip to content

Commit

Permalink
Bundle umd with rollup (#681)
Browse files Browse the repository at this point in the history
  • Loading branch information
TrySound authored and timdorr committed May 18, 2017
1 parent f472fba commit a7a11fc
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 395 deletions.
6 changes: 6 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
"plugins": [
"./build/use-lodash-es"
]
},
"rollup": {
"plugins": [
"./build/use-lodash-es",
"external-helpers"
]
}
}
}
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"scripts": {
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --out-dir lib",
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es",
"build:umd": "cross-env BABEL_ENV=commonjs NODE_ENV=development webpack src/index.js dist/react-redux.js",
"build:umd:min": "cross-env BABEL_ENV=commonjs NODE_ENV=production webpack src/index.js dist/react-redux.min.js",
"build:umd": "cross-env BABEL_ENV=rollup NODE_ENV=development rollup -c -o dist/react-redux.js",
"build:umd:min": "cross-env BABEL_ENV=rollup NODE_ENV=production rollup -c -o dist/react-redux.min.js",
"build": "npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:umd:min",
"clean": "rimraf lib dist es coverage",
"lint": "eslint src test",
Expand Down Expand Up @@ -50,8 +50,8 @@
"babel-cli": "^6.3.17",
"babel-core": "^6.3.26",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.2.0",
"babel-plugin-check-es2015-constants": "^6.3.13",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-istanbul": "^4.0.0",
"babel-plugin-syntax-jsx": "^6.3.13",
"babel-plugin-transform-decorators-legacy": "^1.2.0",
Expand Down Expand Up @@ -92,7 +92,12 @@
"react-dom": "^15.0.0",
"redux": "^3.0.0",
"rimraf": "^2.3.4",
"webpack": "^1.11.0"
"rollup": "^0.41.6",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-replace": "^1.1.1",
"rollup-plugin-uglify": "^1.0.1"
},
"dependencies": {
"create-react-class": "^15.5.1",
Expand Down
47 changes: 47 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import nodeResolve from 'rollup-plugin-node-resolve'
import babel from 'rollup-plugin-babel'
import replace from 'rollup-plugin-replace'
import commonjs from 'rollup-plugin-commonjs'
import uglify from 'rollup-plugin-uglify'

const env = process.env.NODE_ENV

const config = {
entry: 'src/index.js',
external: [
'react',
'redux'
],
globals: {
'react': 'React',
'redux': 'Redux'
},
format: 'umd',
moduleName: 'ReactRedux',
plugins: [
nodeResolve(),
babel({
exclude: '**/node_modules/**'
}),
replace({
'process.env.NODE_ENV': JSON.stringify(env)
}),
commonjs()
]
}

if (env === 'production') {
config.plugins.push(
uglify({
compress: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
screw_ie8: true,
warnings: false
}
})
)
}

export default config
64 changes: 0 additions & 64 deletions webpack.config.js

This file was deleted.

Loading

0 comments on commit a7a11fc

Please sign in to comment.