Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get minified output with browserify?

Just started to use browserify, but I cannot find documentation for how to get it spilling out minified output.

So I am looking something like:

$> browserify main.js > bundle.js --minified 
like image 353
Fdr Avatar asked Mar 23 '13 18:03

Fdr


People also ask

Is Browserify a dev dependency?

We can also include browserify itself as a dependency, however it isn't a dependency for the project to run – any user to our app can find Superman without needing to run Browserify. It is one of our devDependencies – modules required for developers to make updates to this app.

What is Minification and Uglification?

Minifying is just removing unnecessary white-space and redundant like comments and semicolons. And it can be reversed back when needed. Uglifying is transforming the code into an "unreadable" form by changing variable names, function names, etc, to hide the original content.


1 Answers

Pipe it through uglifyjs:

 browserify main.js | uglifyjs > bundle.js 

You can install it using npm like so:

 npm install -g uglify-js 
like image 180
topek Avatar answered Sep 28 '22 07:09

topek