Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Piping browserify with uglify and exorcist in npm scripts

I need help to run a chain of commands in npm scripts when building a js application.

Right now Im running this line:

"scripts": {
    "build-js": "browserify src/app/main.js --debug | exorcist dist/app.js.map > dist/app.js",
}

That browserifies and extracts sourcemaps. But I would also like to minify with uglifyjs2.

How to I pipe uglifyjs to get a minified source with external sourcemaps?

like image 924
Presidenten Avatar asked Dec 25 '22 11:12

Presidenten


2 Answers

uglifyify can help you:

browserify -t uglifyify src/app/main.js --debug | exorcist dist/app.js.map > dist/app.js
like image 150
robertklep Avatar answered Dec 27 '22 21:12

robertklep


You can do this:

"browserify": "browserify -e scripts/index.js -d -t browserify-shim | exorcist scripts/bundle.map | uglifyjs -cm > scripts/bundle.js"
like image 28
Adrian Miranda Avatar answered Dec 27 '22 21:12

Adrian Miranda