Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

gulp-brotli

1.2.1 • Public • Published

gulp-brotli

NPM Version Build Status

gulp-brotli is a gulp plugin for file compression/decompression using the brotli compression library via iltorb.

Usage

Install

npm install gulp-brotli

Options

You can specify an optional options object that is passed on to iltorb for compression, and accepts the following additional properties:

extension String

Defaults to br. Should not include a starting dot.

skipLarger Boolean

Enable this option to skip the compressed buffer if it is bigger than the input.

Defaults to false.

Note: this option will be ignored if the input is not passed to gulp-brotli as a buffer. For example by setting the gulp.src "buffer" option to false.


compress([options])

Default compression

Output files will have the .br extension.

var gulp   = require('gulp');
var brotli = require('gulp-brotli');
 
gulp.task('example', function() {
  return gulp.src('path/to/input')
    .pipe(brotli.compress())
    .pipe(gulp.dest('path/to/output'));
});

Custom compression

Files are processed with maximum compression, output files will have the .brotli extension, and compressed outputs that are larger than the input will not be written to disk.

var gulp   = require('gulp');
var brotli = require('gulp-brotli');
 
gulp.task('example', function() {
  return gulp.src('path/to/input')
    .pipe(brotli.compress({
      extension: 'brotli',
      skipLarger: true,
      mode: 0,
      quality: 11,
      lgblock: 0
    }))
    .pipe(gulp.dest('path/to/output'));
});

decompress([options])

Default decompression

Output files will have the .br extension removed.

var gulp   = require('gulp');
var brotli = require('gulp-brotli');
 
gulp.task('example', function() {
  return gulp.src('path/to/input')
    .pipe(brotli.decompress())
    .pipe(gulp.dest('path/to/output'));
});

Custom decompression

Output files will have the .brotli extension removed.

var gulp   = require('gulp');
var brotli = require('gulp-brotli');
 
gulp.task('example', function() {
  return gulp.src('path/to/input')
    .pipe(brotli.decompress({
      extension: 'brotli'
    }))
    .pipe(gulp.dest('path/to/output'));
});

install

npm i gulp-brotli

Downloadsweekly downloads

1,133

version

1.2.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
Report a vulnerability