# gulp-uglify

> Minify files with UglifyJS.

Latest version **3.0.2** (published 2019-03-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-uglify
pnpm add gulp-uglify
yarn add gulp-uglify
bun add gulp-uglify
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2019-03-01 |
| First published | 2013-07-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/gulp-uglify) |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 12.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1213 |
| Author | Terin Stock |
| Maintainers | terinjokes |
| Keywords | gulpplugin |

## Links

- npm: https://www.npmjs.com/package/gulp-uglify
- Repository: https://github.com/terinjokes/gulp-uglify
- Homepage: https://github.com/terinjokes/gulp-uglify/
- Issues: https://github.com/terinjokes/gulp-uglify/issues
- npm.io page: https://npm.io/package/gulp-uglify

## Dependencies (10)

- [gulplog](https://npm.io/package/gulplog.md) ^1.0.0
- [isobject](https://npm.io/package/isobject.md) ^3.0.1
- [through2](https://npm.io/package/through2.md) ^2.0.0
- [uglify-js](https://npm.io/package/uglify-js.md) ^3.0.5
- [array-each](https://npm.io/package/array-each.md) ^1.0.1
- [has-gulplog](https://npm.io/package/has-gulplog.md) ^0.1.0
- [safe-buffer](https://npm.io/package/safe-buffer.md) ^5.1.2
- [extend-shallow](https://npm.io/package/extend-shallow.md) ^3.0.2
- [make-error-cause](https://npm.io/package/make-error-cause.md) ^1.1.1
- [vinyl-sourcemaps-apply](https://npm.io/package/vinyl-sourcemaps-apply.md) ^0.2.0

## Recent versions

- 3.0.2 (latest) — 2019-03-01
- 3.0.1 — 2018-07-24
- 3.0.0 — 2017-05-20
- 2.1.2 — 2017-03-21
- 2.1.1 — 2017-03-20
- 2.1.0 — 2017-03-09
- 2.0.1 — 2017-01-24
- 2.0.0 — 2016-08-01
- 1.5.4 — 2016-06-22
- 1.5.3 — 2016-02-22
- 1.5.2 — 2016-02-07
- 1.5.1 — 2015-11-13
- 1.4.2 — 2015-10-13
- 1.4.1 — 2015-09-09
- 1.4.0 — 2015-08-28
- … 16 more at https://npm.io/package/gulp-uglify/versions

## README

# gulp-uglify [![][travis-shield-img]][travis-shield][![][appveyor-shield-img]][appveyor-shield][![][npm-dl-shield-img]][npm-shield][![][npm-v-shield-img]][npm-shield][![][coveralls-shield-img]][coveralls-shield]

> Minify JavaScript with UglifyJS3.

## Installation

Install package with NPM and add it to your development dependencies:

`npm install --save-dev gulp-uglify`

## Usage

```javascript
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var pipeline = require('readable-stream').pipeline;

gulp.task('compress', function () {
  return pipeline(
        gulp.src('lib/*.js'),
        uglify(),
        gulp.dest('dist')
  );
});
```

To help properly handle error conditions with Node streams, this project
recommends the use of
[`pipeline`](https://nodejs.org/docs/latest/api/stream.html#stream_stream_pipeline_streams_callback),
from [`readable-stream`](https://github.com/nodejs/readable-stream).

## Options

Most of the [minify options](https://github.com/mishoo/UglifyJS2#minify-options) from
the UglifyJS API are supported. There are a few exceptions:

1. The `sourceMap` option must not be set, as it will be automatically configured
   based on your Gulp configuration. See the documentation for [Gulp sourcemaps][gulp-sm].

[gulp-sm]: https://github.com/gulp-sourcemaps/gulp-sourcemaps#usage

## Errors

`gulp-uglify` emits an 'error' event if it is unable to minify a specific file.
The GulpUglifyError constructor is exported by this plugin for `instanceof` checks.
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:

- `message` (or `msg`)
- `filename`
- `line`

To see useful error messages, see [Why Use Pipeline?](docs/why-use-pipeline/README.md#why-use-pipeline).

## Using a Different UglifyJS

By default, `gulp-uglify` uses the version of UglifyJS installed as a dependency.
It's possible to configure the use of a different version using the "composer" entry point.

```javascript
var uglifyjs = require('uglify-js'); // can be a git checkout
                                     // or another module (such as `uglify-es` for ES6 support)
var composer = require('gulp-uglify/composer');
var pump = require('pump');

var minify = composer(uglifyjs, console);

gulp.task('compress', function (cb) {
  // the same options as described above
  var options = {};

  pump([
      gulp.src('lib/*.js'),
      minify(options),
      gulp.dest('dist')
    ],
    cb
  );
});
```

[travis-shield-img]: https://img.shields.io/travis/terinjokes/gulp-uglify/master.svg?label=Travis%20CI&style=flat-square
[travis-shield]: https://travis-ci.org/terinjokes/gulp-uglify
[appveyor-shield-img]: https://img.shields.io/appveyor/ci/terinjokes/gulp-uglify/master.svg?label=AppVeyor&style=flat-square
[appveyor-shield]: https://ci.appveyor.com/project/terinjokes/gulp-uglify
[npm-dl-shield-img]: https://img.shields.io/npm/dm/gulp-uglify.svg?style=flat-square
[npm-shield]: https://yarnpkg.com/en/package/gulp-uglify
[npm-v-shield-img]: https://img.shields.io/npm/v/gulp-uglify.svg?style=flat-square
[coveralls-shield-img]: https://img.shields.io/coveralls/terinjokes/gulp-uglify/master.svg?style=flat-square
[coveralls-shield]: https://coveralls.io/github/terinjokes/gulp-uglify

---
_Source: https://npm.io/package/gulp-uglify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
