├── README.md ├── index.js └── package.json /README.md: -------------------------------------------------------------------------------- 1 | # Gulp CSS Statistics 2 | 3 | Gulp plugin version of http://cssstats.com 4 | 5 | ## Usage 6 | 7 | ```js 8 | var gulp = require('gulp'); 9 | var cssstats = require('gulp-cssstats'); 10 | 11 | gulp.task('cssstats', function() { 12 | gulp.src('./base.css') 13 | .pipe(cssstats()) 14 | .pipe(gulp.dest('./')); 15 | }); 16 | ``` 17 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 2 | var path = require('path'); 3 | var through = require('through2'); 4 | var cssstats = require('cssstats'); 5 | 6 | module.exports = function(options) { 7 | 8 | options = options || {}; 9 | 10 | return through.obj(function(file, encoding, callback) { 11 | 12 | if (!file.isBuffer()) callback(); 13 | 14 | var src = file.contents.toString(); 15 | var obj = cssstats(src, options); 16 | 17 | file.contents = new Buffer(JSON.stringify(obj, null, 2)); 18 | 19 | file.path = path.join(path.dirname(file.path), path.basename(file.path, path.extname(file.path)) + '.json'); 20 | 21 | this.push(file); 22 | callback(); 23 | 24 | }); 25 | 26 | }; 27 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gulp-cssstats", 3 | "version": "1.0.1", 4 | "description": "Gulp plugin for CSS Stats", 5 | "main": "index.js", 6 | "author": "Brent Jackson", 7 | "license": "MIT", 8 | "dependencies": { 9 | "cssstats": "latest", 10 | "through2": "^0.6.3" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/jxnblk/gulp-cssstats.git" 15 | }, 16 | "bugs": { 17 | "url": "https://github.com/jxnblk/gulp-cssstats/issues" 18 | }, 19 | "homepage": "https://github.com/jxnblk/gulp-cssstats" 20 | } 21 | --------------------------------------------------------------------------------