Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/philmander/gulp-warn-size
Gulp plugin that warns when a file exceeds a given size limit"
https://github.com/philmander/gulp-warn-size
Last synced: about 1 month ago
JSON representation
Gulp plugin that warns when a file exceeds a given size limit"
- Host: GitHub
- URL: https://github.com/philmander/gulp-warn-size
- Owner: philmander
- Created: 2016-03-30T12:15:59.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-03-30T14:42:30.000Z (over 8 years ago)
- Last Synced: 2024-10-11T01:55:29.944Z (3 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gulp-warn-size
> Warns if a file in a stream exceeds a given limit
## Install
```
$ npm install --save-dev gulp-warn-size
```## Usage
```js
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](https://github.com/sindresorhus/gulp-size) for this.
## API
### warn-size(limit)
Type: `number`
RequiredThe 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`
RequiredSame 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: trueDisplays prettified size: `1337 B` → `1.34 kB`.
## License
MIT. Phil Mander.
Adapted from gulp-size