Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate UMD build with Rollup #964

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -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';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about process.argv.indexOf('--prod') >= 0, then it can be on any argument.

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);
});
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,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",
Expand Down Expand Up @@ -71,6 +71,10 @@
"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",
"uglifyjs": "^2.4.10",
"webpack": "^1.9.6"
},
"npmName": "redux",
Expand Down