Minify files with UglifyJS.
Install package with NPM and add it to your development dependencies:
npm install --save-dev gulp-uglify
var gulp = ;var uglify = ;var pump = ;gulp;
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.
The GulpUglifyError constructor is exported by this plugin for
It contains the following properties:
fileName: The full file path for the file being minified.
cause: The original UglifyJS error, if available.
Most UglifyJS error messages have the following properties:
To see useful error messages, see Why Use Pump?.
gulp-uglify uses the version of UglifyJS installed as a dependency.
It's possible to configure the use of a different version using the "minifier" entry point.
var uglifyjs = ; // can be a git checkout// or another module (such as `uglify-js-harmony` for ES6 support)var minifier = ;var pump = ;gulp;