├── .gitattributes ├── .gitignore ├── .editorconfig ├── gulpfile.js ├── .jshintrc ├── index.js ├── package.json ├── LICENSE ├── test.js └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | ./dest -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = tab 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var uncss = require('gulp-uncss-task'); 3 | 4 | gulp.task('default', function() { 5 | gulp.src('bootstrap.css') 6 | .pipe(uncss({ 7 | html: ['index.html', 'contact.html', 'about.html'] 8 | })) 9 | .pipe(gulp.dest('dest')); 10 | }); 11 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "esnext": true, 4 | "bitwise": true, 5 | "camelcase": true, 6 | "curly": true, 7 | "eqeqeq": true, 8 | "immed": true, 9 | "indent": 4, 10 | "latedef": true, 11 | "newcap": true, 12 | "noarg": true, 13 | "quotmark": "single", 14 | "regexp": true, 15 | "undef": true, 16 | "unused": true, 17 | "strict": true, 18 | "trailing": true, 19 | "smarttabs": true 20 | } -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var es = require('event-stream'); 3 | var uncss = require('uncss'); 4 | 5 | module.exports = function() { 6 | var args = arguments; 7 | var input = args[0].html; 8 | var options = {}; 9 | 10 | options.csspath = args[0].csspath; 11 | options.stylesheets = args[0].stylesheets; 12 | options.ignore = args[0].ignore; 13 | options.timeout = args[0].timeout; 14 | 15 | return es.map(function(file, cb){ 16 | options.raw = String(file.contents); 17 | uncss(input, options, function(output){ 18 | file.contents = new Buffer(output); 19 | cb(null, file); 20 | }); 21 | }); 22 | }; 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gulp-uncss-task", 3 | "version": "0.3.0", 4 | "description": "A Gulp task for removing unused CSS", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "test" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/addyosmani/gulp-uncss-task" 12 | }, 13 | "keywords": [ 14 | "uncss", 15 | "unused", 16 | "css", 17 | "gulpplugin" 18 | ], 19 | "dependencies": { 20 | "event-stream": "~3.1.0", 21 | "gulp-util": "~2.2.14", 22 | "uncss": "~0.8.0" 23 | }, 24 | "devDependencies": { 25 | "mocha": "*", 26 | "gulp": "~3.5.6" 27 | }, 28 | "author": { 29 | "name": "Addy Osmani", 30 | "email": "addyosmani@gmail.com", 31 | "url": "http://addyosmani.com" 32 | }, 33 | "scripts": { 34 | "test": "mocha" 35 | }, 36 | "license": "MIT", 37 | "bugs": { 38 | "url": "https://github.com/addyosmani/gulp-uncss-task/issues" 39 | }, 40 | "homepage": "https://github.com/addyosmani/gulp-uncss-task" 41 | } 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Addy Osmani 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var assert = require('assert'); 3 | var gutil = require('gulp-util'); 4 | var uncss = require('./index'); 5 | 6 | var html = '