From 78d98e856abb23207cb9097aedf3d012eac68dcb Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Tue, 27 Oct 2015 18:56:09 -0400 Subject: [PATCH 1/2] Generate UMD build with Rollup --- build.js | 22 ++++++++++++++++++++++ package.json | 9 ++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 build.js diff --git a/build.js b/build.js new file mode 100644 index 0000000000..10356047cf --- /dev/null +++ b/build.js @@ -0,0 +1,22 @@ +var rollup = require( 'rollup' ); +var babel = require( 'rollup-plugin-babel' ); +var replace = require( 'rollup-plugin-replace' ); + +var env = process.argv[2] === '--prod' ? 'production' : 'development'; + +rollup.rollup({ + entry: 'src/index.js', + plugins: [ + replace({ + 'process.env.NODE_ENV': JSON.stringify(env) + }), + babel() + ] +}).then(function (bundle) { + var code = bundle.generate({ + format: 'umd', + moduleName: 'Redux' + }).code; + + process.stdout.write(code); +}); diff --git a/package.json b/package.json index a34f97655e..fed1ca1c3d 100644 --- a/package.json +++ b/package.json @@ -13,10 +13,10 @@ "test:examples": "babel-node examples/testAll.js", "check": "npm run lint && npm run test", "build:lib": "babel src --out-dir lib", - "build:umd": "webpack src/index.js dist/redux.js --config webpack.config.development.js", - "build:umd:min": "webpack src/index.js dist/redux.min.js --config webpack.config.production.js", + "build:umd": "node build.js > dist/redux.js", + "build:umd:min": "node build.js --prod | uglifyjs -c warnings=false -m --screw-ie8 > dist/redux.min.js", "build:examples": "babel-node examples/buildAll.js", - "build": "npm run build:lib && npm run build:umd && npm run build:umd:min", + "build": "npm run build:lib && rm -rf dist && mkdir -p dist && npm run build:umd && npm run build:umd:min", "preversion": "npm run clean && npm run check", "version": "npm run build", "postversion": "git push && git push --tags && npm run clean && npm run docs:publish", @@ -66,6 +66,9 @@ "isparta": "^3.0.3", "mocha": "^2.2.5", "rimraf": "^2.3.4", + "rollup": "^0.20.2", + "rollup-plugin-babel": "^1.0.0", + "rollup-plugin-replace": "^1.0.1", "webpack": "^1.9.6" }, "npmName": "redux", From fd2cc3369a658c0b4520cee9700d1653fed00e11 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Tue, 27 Oct 2015 19:10:54 -0400 Subject: [PATCH 2/2] install uglifyjs as devDependency --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index fed1ca1c3d..4afba1253b 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ "rollup": "^0.20.2", "rollup-plugin-babel": "^1.0.0", "rollup-plugin-replace": "^1.0.1", + "uglifyjs": "^2.4.10", "webpack": "^1.9.6" }, "npmName": "redux",