UNPKG

2.02 kBMarkdownView Raw
1# gulp-uglify [![Build Status](http://img.shields.io/travis/terinjokes/gulp-uglify.svg?style=flat)](https://travis-ci.org/terinjokes/gulp-uglify) [![](http://img.shields.io/npm/dm/gulp-uglify.svg?style=flat)](https://www.npmjs.org/package/gulp-uglify) [![](http://img.shields.io/npm/v/gulp-uglify.svg?style=flat)](https://www.npmjs.org/package/gulp-uglify) [![](http://img.shields.io/codeclimate/github/terinjokes/gulp-uglify.svg?style=flat)](https://codeclimate.com/github/terinjokes/gulp-uglify) [![](http://img.shields.io/codeclimate/coverage/github/terinjokes/gulp-uglify.svg?style=flat)](https://codeclimate.com/github/terinjokes/gulp-uglify)
2
3> Minify JavaScript with UglifyJS2.
4
5## Installation
6
7Install package with NPM and add it to your development dependencies:
8
9`npm install --save-dev gulp-uglify`
10
11## Usage
12
13```javascript
14var uglify = require('gulp-uglify');
15
16gulp.task('compress', function() {
17 gulp.src('lib/*.js')
18 .pipe(uglify())
19 .pipe(gulp.dest('dist'))
20});
21```
22
23## Options
24
25- `mangle`
26
27 Pass `false` to skip mangling names.
28
29- `output`
30
31 Pass an object if you wish to specify additional [output
32 options](http://lisperator.net/uglifyjs/codegen). The defaults are
33 optimized for best compression.
34
35- `compress`
36
37 Pass an object to specify custom [compressor
38 options](http://lisperator.net/uglifyjs/compress). Pass `false` to skip
39 compression completely.
40
41- `preserveComments`
42
43 A convenience option for `options.output.comments`. Defaults to preserving no
44 comments.
45
46 - `all`
47
48 Preserve all comments in code blocks
49
50 - `some`
51
52 Preserve comments that start with a bang (`!`) or include a Closure
53 Compiler directive (`@preserve`, `@license`, `@cc_on`)
54
55 - `function`
56
57 Specify your own comment preservation function. You will be passed the
58 current node and the current comment and are expected to return either
59 `true` or `false`.
60
61You can also pass the `uglify` function any of the options [listed
62here](https://github.com/mishoo/UglifyJS2#the-simple-way) to modify
63UglifyJS's behavior.