uglify-stream
v1.1.0
Published
Transform stream for UglifyJS
Downloads
75
Maintainers
Readme
uglify-stream
Transform stream for UglifyJS
Example
var fs = require('fs');
var uglify = require('uglify-stream');
fs.createReadStream('input.js')
.pipe(uglify())
.pipe(fs.createWriteStream('output.js'));
API
uglify-stream([opts])
Creates a duplex stream that will compress all JS code piped into it with UglifyJS. UglifyJS is run in a separate process when using this module, which means that it will not block the calling process when compressing, unlike using Uglify directly from Node.
Options
compress
: Set tofalse
to disable compressionmangle
: Set tofalse
to disable name mangling
Example: compress browserify bundle
Using a transform stream makes it very simple to compress the bundle output from Browserify:
var browserify = require('browserify');
var uglify = require('uglify-stream');
var bl = require('bl');
var b = browserify('my-file.js')
.bundle()
.pipe(uglify())
.pipe(bl(done));
function done(err, src) {
console.log(src.toString());
}