Minify files with UglifyJS.
Install package with NPM and add it to your development dependencies:
npm install --save-dev gulp-uglify
var uglify = require'gulp-uglify';gulptask'compress'return gulpsrc'lib/*.js'pipeuglifypipegulpdest'dist';;
false to skip mangling names.
Pass an object if you wish to specify additional output options. The defaults are optimized for best compression.
Pass an object to specify custom compressor
false to skip
A convenience option for
options.output.comments. Defaults to preserving no
Preserve all comments in code blocks
Attempts to preserve comments that likely contain licensing information,
even if the comment does not have directives such as
Implemented via the
module, this option preserves a comment if one of the following is true:
Specify your own comment preservation function. You will be passed the
current node and the current comment and are expected to return either
Preserve comments that start with a bang (
!) or include a Closure Compiler
Deprecated in favor of the
license option, documented above.
You can also pass the
uglify function any of the options listed
here to modify
gulp-uglify emits an 'error' event if it is unable to minify a specific file.
Wherever possible, the PluginError object will contain the following properties:
To handle errors across your entire pipeline, see the gulp documentation.