Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sindresorhus/gulp-size
Display the size of your project
https://github.com/sindresorhus/gulp-size
gulp-plugin gzip javascript nodejs size
Last synced: about 1 month ago
JSON representation
Display the size of your project
- Host: GitHub
- URL: https://github.com/sindresorhus/gulp-size
- Owner: sindresorhus
- License: mit
- Created: 2014-01-03T18:26:38.000Z (almost 11 years ago)
- Default Branch: main
- Last Pushed: 2023-10-31T21:38:18.000Z (about 1 year ago)
- Last Synced: 2024-04-13T21:23:58.796Z (7 months ago)
- Topics: gulp-plugin, gzip, javascript, nodejs, size
- Language: JavaScript
- Size: 111 KB
- Stars: 229
- Watchers: 6
- Forks: 16
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# gulp-size
> Display the size of your project
Logs out the total size of files in the stream and optionally the individual file-sizes.
## Install
```sh
npm install --save-dev gulp-size
```## Usage
```js
import gulp from 'gulp';
import size from 'gulp-size';export default () => (
gulp.src('fixture.js')
.pipe(size())
.pipe(gulp.dest('dist'))
);
```## API
### size(options?)
#### options
Type: `object`
##### title
Type: `string`\
Default: `''`Give it a title so it's possible to distinguish the output of multiple instances logging at once.
##### gzip
Type: `boolean`\
Default: `false`Displays the gzipped size.
##### brotli
Type: `boolean`\
Default: `false`Displays the brotli compressed size.
##### uncompressed
Type: `boolean`\
Default: `false` if either of gzip or brotli is `true`, otherwise `true`Displays the uncompressed size.
##### pretty
Type: `boolean`\
Default: `true`Displays prettified size: `1337 B` → `1.34 kB`.
##### showFiles
Type: `boolean`\
Default: `false`Displays the size of every file instead of just the total size.
##### showTotal
Type: `boolean`\
Default: `true`Displays the total of all files.
### size.size
Type: `number`\
Example: `12423000`The total size of all files in bytes.
### size.prettySize
Type: `string`\
Example: `14 kB`Prettified version of `.size`.
#### Example
You could, for example, use this to report the total project size with [`gulp-notify`](https://github.com/mikaelbr/gulp-notify):
```js
import gulp from 'gulp';
import size from 'gulp-size';
import notify from 'gulp-notify';export default () => (
exports.default = () => {
const sizeInstance = size();return gulp.src('fixture.js')
.pipe(sizeInstance)
.pipe(gulp.dest('dist'))
.pipe(notify({
onLast: true,
message: () => `Total size ${sizeInstance.prettySize}`
}));
};
```