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",