minify javascript in a stream using uglify-js
npm install minify-stream
var minifyStream = require('minify-stream') fs.createReadStream('app.js') .pipe(minifyStream()) .pipe(fs.createWriteStream('app.min.js'))
Create a new minify stream. Write a Javascript file or bundle to it.
Possible options are:
uglify- An uglify module to use, defaults toterser. It must have an uglify-compatibleminify()function.- All other options are passed to the
minify()function as the second parameter. See the terser docs for available options.
minify-stream adds inline source maps by default. Use exorcist
to extract source maps from the output stream into a separate file. If you don't need source maps, pass
the sourceMap: false option to disable them.
minifyStream({ sourceMap: false })