# gulp-gzip

> Gzip plugin for gulp.

Latest version **1.4.2** (published 2018-01-20) · MIT license · 0 weekly downloads

## Install

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

## 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 | 1.4.2 |
| Published | 2018-01-20 |
| First published | 2013-10-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/gulp-gzip) |
| Module format | CommonJS |
| Node | >= 0.10.0 |
| Dependencies | 6 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 172 |
| Author | Jeremy Stuckey |
| Maintainers | jstuckey |
| Keywords | compress, gulpplugin, gzip |

## Links

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

## Dependencies (6)

- [bytes](https://npm.io/package/bytes.md) ^3.0.0
- [through2](https://npm.io/package/through2.md) ^2.0.3
- [fancy-log](https://npm.io/package/fancy-log.md) ^1.3.2
- [ansi-colors](https://npm.io/package/ansi-colors.md) ^1.0.1
- [plugin-error](https://npm.io/package/plugin-error.md) ^1.0.0
- [stream-to-array](https://npm.io/package/stream-to-array.md) ^2.3.0

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 1.4.2 (latest) — 2018-01-20
- 1.4.1 — 2018-01-02
- 1.4.0 — 2016-06-01
- 1.3.0 — 2016-05-11
- 1.2.0 — 2015-07-18
- 1.1.0 — 2015-03-24
- 1.0.0 — 2015-02-18
- 0.0.8 — 2014-04-24
- 0.0.7 — 2014-04-16
- 0.0.6 — 2014-04-10
- 0.0.5 — 2014-02-10
- 0.0.4 — 2014-01-10
- 0.0.3 — 2014-01-07
- 0.0.2 — 2013-10-25
- 0.0.1 — 2013-10-23

## README

gulp-gzip
=========

Gzip plugin for [gulp](https://github.com/wearefractal/gulp).

 # Install

```
npm install --save-dev gulp-gzip
```

# Options

### append `Boolean`

Appends `.gz` file extension if true. Defaults to true.

```javascript
 gzip({ append: true })
```
`filename.txt` becomes `filename.txt.gz`.

### extension `String`

Appends an arbitrary extension to the filename. Disables `append` and `preExtension` options.

```javascript
 gzip({ extension: 'zip' }) // note that the `.` should not be included in the extension
```
`filename.txt` becomes `filename.txt.zip`.

### preExtension `String`

Appends an arbitrary pre-extension to the filename. Disables `append` and `extension` options.

```javascript
 gzip({ preExtension: 'gz' }) // note that the `.` should not be included in the extension
```
`filename.txt` becomes `filename.gz.txt`.

### threshold `String|Number|Boolean`

Minimum size required to compress a file. Defaults to false.

```javascript
gzip({ threshold: '1kb' })
```

```javascript
gzip({ threshold: 1024 })
```

```javascript
gzip({ threshold: true })
```

### gzipOptions `Object`

Options object to pass through to zlib.Gzip. See [zlib documentation][gzip-options] for more information.

```javascript
gzip({ gzipOptions: { level: 9 } })
```

```javascript
gzip({ gzipOptions: { memLevel: 1 } })
```

### deleteMode `String|Function`

Some webserver modules such as nginx `gzip_static` looks for `example.html.gz`, serve it if it exists, else the original `example.html` will be served.

For instance, if `example.html` was 2kb, it would be gzipped and `example.html.gz` was created.

However, if later `example.html` is modified to content less than the threshold, gulp-gzip will only bypass it. Hence, you will end up with a new `example.html` yet old `example.html.gz`. Your webserver will continue to serve old content (`example.html.gz`).

Using this option, gulp-gzip will remove `example.html.gz`.

It takes in the same argument as `gulp.dest` as in `gulp.dest('mydest')`, so it knows where to look for the gzipped files. Defaults to `undefined`.

```javascript
gzip({ threshold: 1024, deleteMode: 'mydest' })
```

If you have `cwd` as in `gulp.dest('mydest', { cwd: mycwd })`. You can configure it using `deleteModeCwd`.

```javascript
gzip({ threshold: 1024, deleteMode: 'mydest', deleteModeCwd: mycwd })
```

### skipGrowingFiles `Boolean`

Some files actually get larger after compression. If true, this option passes along the original, uncompressed file if compression increases the file size. Defaults to false.

```javascript
 gzip({ skipGrowingFiles : true })
```

# Examples

```javascript
var gulp = require('gulp');
var gzip = require('gulp-gzip');

gulp.task('compress', function() {
    gulp.src('./dev/scripts/*.js')
	.pipe(gzip())
	.pipe(gulp.dest('./public/scripts'));
});
```

```javascript
var gulp = require('gulp');
var coffee = require('gulp-coffee');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var gzip = require('gulp-gzip');

gulp.task('deployScripts', function() {
	gulp.src('./dev/scripts/*.coffee')
	.pipe(coffee())
	.pipe(concat('all.js'))
	.pipe(uglify())
	.pipe(gzip())
	.pipe(gulp.dest('./public/scripts'));
});
```

```javascript
var gulp = require('gulp');
var tar = require('gulp-tar');
var gzip = require('gulp-gzip');

gulp.task('tarball', function() {
	gulp.src('./files/*')
	.pipe(tar('archive.tar'))
	.pipe(gzip())
	.pipe(gulp.dest('.'));
});
```

[More examples](https://github.com/jstuckey/gulp-gzip/tree/master/examples).


  [gzip-options]: https://nodejs.org/api/zlib.html#zlib_class_options

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