0.2.0 • Published 8 years ago

gulp-warn-size v0.2.0

Weekly downloads
8
License
MIT
Repository
github
Last release
8 years ago

gulp-warn-size

Warns if a file in a stream exceeds a given limit

Install

$ npm install --save-dev gulp-warn-size

Usage

const gulp = require('gulp');
const size = require('gulp-warn-size');

gulp.task('default', () =>
	gulp.src('fixture.js')
		.pipe(warn-size(2048)) //should not exceed 2kb
		.on('error', () => process.exit(1))
		.pipe(gulp.dest('dist'))
);

gulp-warn-size does not display sizes. Use gulp-size for this.

API

warn-size(limit)

Type: number Required

The file size limit in bytes. Negative values will be ignored. Other values will cause the plugin to fail.

warn-size(options)

options

limit

Type: number Required

Same as above

errorOnFail

Type: boolean Default: true

Emits an error from the stream if a file exceeds the given limit. Otherwise, just a warning will be logged to the console

filter

Type: RegExp Default: /.*/

Only applies file size checking to files which match this pattern. E.g.

gulp.src('src/**/*')
    .pipe(warn-size({
        limit: 2048,
        filter: /\.js$/ //only check JS files
    }))
    .pipe(gulp.dest('dist'))
pretty

Type: boolean Default: true

Displays prettified size: 1337 B1.34 kB.

License

MIT. Phil Mander.

Adapted from gulp-size