# gulp-minify

> Js minify plugin for gulp

Latest version **3.1.0** (published 2018-06-30) · ISC license · 0 weekly downloads

## Install

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

## 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.1.0 |
| Published | 2018-06-30 |
| First published | 2014-08-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/gulp-minify) |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 9.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 65 |
| Author | 308512341@qq.com |
| Maintainers | taojie |

## Links

- npm: https://www.npmjs.com/package/gulp-minify
- Repository: https://github.com/hustxiaoc/gulp-minify
- Issues: https://github.com/hustxiaoc/gulp-minify/issues
- npm.io page: https://npm.io/package/gulp-minify

## Dependencies (6)

- [vinyl](https://npm.io/package/vinyl.md) ^2.1.0
- [terser](https://npm.io/package/terser.md) ^3.7.6
- [through2](https://npm.io/package/through2.md) ^2.0.3
- [minimatch](https://npm.io/package/minimatch.md) ^3.0.2
- [ansi-colors](https://npm.io/package/ansi-colors.md) ^1.0.1
- [plugin-error](https://npm.io/package/plugin-error.md) ^0.1.2

## Recent versions

- 3.1.0 (latest) — 2018-06-30
- 0.0.15 (es5) — 2017-02-04
- 3.0.2 — 2018-06-12
- 3.0.1 — 2018-06-12
- 3.0.0 — 2018-06-11
- 2.1.0 — 2017-11-07
- 1.0.0 — 2017-05-12
- 0.0.14 — 2016-08-06
- 0.0.13 — 2016-07-20
- 0.0.12 — 2016-06-03
- 0.0.11 — 2016-04-26
- 0.0.10 — 2016-04-20
- 0.0.9 — 2016-04-16
- 0.0.8 — 2016-04-16
- 0.0.7 — 2016-03-19
- … 7 more at https://npm.io/package/gulp-minify/versions

## README

# gulp-minify

> Minify JavaScript with terser.

[![Build Status](https://travis-ci.org/hustxiaoc/gulp-minify.svg?branch=master)](https://travis-ci.org/hustxiaoc/gulp-minify)
[![NPM version](https://badge.fury.io/js/gulp-minify.svg)](http://badge.fury.io/js/gulp-minify)

## Note

The latest version of  `gulp-minify` is using [terser](https://www.npmjs.com/package/terser) to minify files, this may cause some incompatible issues with earlier language versions for now, see https://github.com/hustxiaoc/gulp-minify/issues/27.

So `gulp-minify@es5` is for the earlier language versions if your project is not ready for the ECMAScript 6 yet.

## Installation

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

`npm install --save-dev gulp-minify`

## Usage

_Basic usage_: the following minifies every `*.js` and `*.mjs` files to `*-min.js` and `*-min.mjs` respectively. Note that the original files are preserved.

```javascript
const minify = require('gulp-minify');

gulp.task('compress', function() {
  gulp.src(['lib/*.js', 'lib/*.mjs'])
    .pipe(minify())
    .pipe(gulp.dest('dist'))
});
```

Options can be added to control more finely what's happening, for example:

```javascript
const minify = require('gulp-minify');

gulp.task('compress', function() {
  gulp.src('lib/*.js')
    .pipe(minify({
        ext:{
            src:'-debug.js',
            min:'.js'
        },
        exclude: ['tasks'],
        ignoreFiles: ['.combo.js', '-min.js']
    }))
    .pipe(gulp.dest('dist'))
});
```

## Options

- `ext`
    An object that specifies output src and minified file extensions.

    - `src`

        The suffix string of the filenames that output source files ends with.

    - `min`

        - When **string**: The suffix string of the filenames that output minified files ends with.
        - When **Array**: The regex expressions to be replaced with input filenames. For example: `[/\.(.*)-source\.js$/, '$1.js']`

- `exclude`

    Will not minify files in the dirs.

- `noSource`
    Will not output the source code in the dest dirs.

- `ignoreFiles`

    Will not minify files which matches the pattern.

- `mangle`

    Pass `false` to skip mangling names.

- `output`

    Pass an object if you wish to specify additional [output
    options](http://lisperator.net/uglifyjs/codegen). The defaults are
    optimized for best compression.

- `compress`

    Pass an object to specify custom [compressor
    options](http://lisperator.net/uglifyjs/compress). Pass `false` to skip
    compression completely.

- `preserveComments`

    A convenience option for `options.output.comments`. Defaults to preserving no
    comments.

    - `all`

        Preserve all comments in code blocks

    - `some`

        Preserve comments that start with a bang (`!`) or include a Closure
        Compiler directive (`@preserve`, `@license`, `@cc_on`)

    - `function`

        Specify your own comment preservation function. You will be passed the
        current node and the current comment and are expected to return either
        `true` or `false`.

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