1.4.2 • Published 7 years ago

gulp-gzip v1.4.2

Weekly downloads
37,971
License
MIT
Repository
github
Last release
7 years ago

gulp-gzip

Gzip plugin for gulp.

Install

npm install --save-dev gulp-gzip

Options

append Boolean

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

 gzip({ append: true })

filename.txt becomes filename.txt.gz.

extension String

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

 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.

 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.

gzip({ threshold: '1kb' })
gzip({ threshold: 1024 })
gzip({ threshold: true })

gzipOptions Object

Options object to pass through to zlib.Gzip. See zlib documentation for more information.

gzip({ gzipOptions: { level: 9 } })
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.

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

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

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.

 gzip({ skipGrowingFiles : true })

Examples

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'));
});
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'));
});
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.

design-system-of-a-down@infinitebrahmanuniverse/nolb-gulp-g@everything-registry/sub-chunk-1807tepez-static-websitewalnut-build-jswwydsapphirereacty-frameworkrgb-generatorutvminified-angularlkd-gulp-taskslogin-web-componentlightweb-builderliferay-compress-cssinterstellarmaintained-moonbaseimago-gulp-angulargulp-build-bitrix-modulgulp-build-bitrix-modulegulp-easygulp-magepackgulp-pbuildgulp-haxetoolgulp-web-compressgulp-standard-tasksgulpurygulp-auto-buildgulp-devkitgulp-frontend-toolsgulp-bitrix-module-buildjumprope-cmsjekyll-postcss-browserifyharno-buildluminous-gulppackagebuilderowpackplugin-gulp-utilsokminngstarter-gzip-tasksnixin-cling-boltpenthouse-idepegakit-build-toolsng-gulprapid-buildsmokegen-gulpsnp-gulp-taskstypeprojecttnt.newick1000-packagesvirteom.public.common-gulp-tasksts-binzeta-packerzeta-packer-amdzeta-packer-batezeta-packer-beta@dvhb/webpack@dvhb/cli@firma-de/gulp-package@ekolabs/project-kit@egis/build-tools@eventured/static-generator@gkodo/gulp-runner@lojaskd/gulp-tasks@microfocus/ng-gulp@ngstarter/gzip-extension@nlemoine/gulp-tasks@revenue-guard/rg-npm-dev@pegakit/build-tools@synetic/compile-styles@pearson-ux/video@pearson-ux/checkbox@pearson-ux/icon@pearson-ux/input@pearson-ux/login@pearson-ux/radio@pearson-ux/range-slider@pearson-ux/search-card@pearson-ux/select@pearson-ux/textarea@zxnode/buildalpha-grid@wanmi/xwidget-cli@z1399/zeta-packer-beta@z1399/zeta-packerape-gulpchickendinosaur-packagebuilderchassisjscommon-assetscordovaboxchronostorecomponents-builderdesign-system-pe-betadevelo-clidoomjsebashdynaware-gulp-taskselasticsidebarbendystraw
1.4.2

7 years ago

1.4.1

7 years ago

1.4.0

8 years ago

1.3.0

9 years ago

1.2.0

9 years ago

1.1.0

10 years ago

1.0.0

10 years ago

0.0.8

11 years ago

0.0.7

11 years ago

0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago