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 = ;const size = ; gulp;
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 B
→ 1.34 kB
.
License
MIT. Phil Mander.
Adapted from gulp-size