grunt-contrib-cssmin
Advanced tools
Comparing version 0.8.0 to 0.9.0
{ | ||
"name": "grunt-contrib-cssmin", | ||
"description": "Compress CSS files.", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"homepage": "https://github.com/gruntjs/grunt-contrib-cssmin", | ||
@@ -32,3 +32,3 @@ "author": { | ||
"clean-css": "~2.1.0", | ||
"grunt-lib-contrib": "~0.6.0" | ||
"maxmin": "~0.1.0" | ||
}, | ||
@@ -35,0 +35,0 @@ "devDependencies": { |
@@ -49,16 +49,8 @@ # grunt-contrib-cssmin v0.8.0 [![Build Status](https://travis-ci.org/gruntjs/grunt-contrib-cssmin.png?branch=master)](https://travis-ci.org/gruntjs/grunt-contrib-cssmin) | ||
#### report | ||
Choices: `false`, `'min'`, `'gzip'` | ||
Default: `false` | ||
Choices: `'min'`, `'gzip'` | ||
Default: `'min'` | ||
Either do not report anything, report only minification result, or report minification and gzip results. | ||
This is useful to see exactly how well clean-css is performing but using `'gzip'` will make the task take 5-10x longer to complete. | ||
Either report only minification result or report minification and gzip results. | ||
This is useful to see exactly how well clean-css is performing but using `'gzip'` will make the task take 5-10x longer to complete. [Example output](https://github.com/sindresorhus/maxmin#readme). | ||
Example ouput using `'gzip'`: | ||
``` | ||
Original: 198444 bytes. | ||
Minified: 101615 bytes. | ||
Gzipped: 20084 bytes. | ||
``` | ||
### Usage Examples | ||
@@ -108,3 +100,3 @@ | ||
* 2013-02-14 v0.8.0 update clean-css v2.1.0 | ||
* 2014-02-14 v0.8.0 update clean-css v2.1.0 | ||
* 2013-11-23 v0.7.0 update clean-css v2.0.0 | ||
@@ -129,2 +121,2 @@ * 2013-09-14 v0.6.2 Support relative URLs via clean-css ~1.1.1. | ||
*This file was generated on Mon Feb 17 2014 14:49:35.* | ||
*This file was generated on Sat Mar 01 2014 19:58:58.* |
@@ -5,3 +5,3 @@ /* | ||
* | ||
* Copyright (c) 2013 Tim Branyen, contributors | ||
* Copyright (c) 2014 Tim Branyen, contributors | ||
* Licensed under the MIT license. | ||
@@ -11,18 +11,27 @@ */ | ||
'use strict'; | ||
var path = require('path'); | ||
var CleanCSS = require('clean-css'); | ||
var chalk = require('chalk'); | ||
var maxmin = require('maxmin'); | ||
module.exports = function(grunt) { | ||
var helper = require('grunt-lib-contrib').init(grunt); | ||
var path = require('path'); | ||
var CleanCSS = require('clean-css'); | ||
var chalk = require('chalk'); | ||
var minify = function(source, options) { | ||
try { | ||
return new CleanCSS(options).minify(source); | ||
} catch (err) { | ||
grunt.log.error(err); | ||
grunt.fail.warn('CSS minification failed.'); | ||
} | ||
}; | ||
grunt.registerMultiTask('cssmin', 'Minify CSS files', function() { | ||
grunt.registerMultiTask('cssmin', 'Minify CSS', function() { | ||
var options = this.options({ | ||
report: false | ||
report: 'min' | ||
}); | ||
this.files.forEach(function(f) { | ||
var valid = f.src.filter(function(filepath) { | ||
this.files.forEach(function(file) { | ||
var valid = file.src.filter(function(filepath) { | ||
// Warn on and remove invalid source files (if nonull was set). | ||
if (!grunt.file.exists(filepath)) { | ||
grunt.log.warn('Source file "' + filepath + '" not found.'); | ||
grunt.log.warn('Source file ' + chalk.cyan(filepath) + ' not found.'); | ||
return false; | ||
@@ -33,37 +42,24 @@ } else { | ||
}); | ||
var max; | ||
if(options.report) { | ||
max = valid | ||
.map(grunt.file.read) | ||
.join(grunt.util.normalizelf(grunt.util.linefeed)); | ||
var max = ''; | ||
var min = valid.map(function(file) { | ||
var src = grunt.file.read(file); | ||
max += src; | ||
options.relativeTo = path.dirname(file); | ||
return minify(src, options); | ||
}).join(''); | ||
if (min.length === 0) { | ||
return grunt.log.warn('Destination not written because minified CSS was empty.'); | ||
} | ||
var min = valid.map(function(f) { | ||
options.relativeTo = path.dirname(f); | ||
return minifyCSS(grunt.file.read(f), options); | ||
}) | ||
.join(''); | ||
if (min.length < 1) { | ||
grunt.log.warn('Destination not written because minified CSS was empty.'); | ||
} else { | ||
if ( options.banner ) { | ||
min = options.banner + grunt.util.linefeed + min; | ||
} | ||
grunt.file.write(f.dest, min); | ||
grunt.log.writeln('File ' + chalk.cyan(f.dest) + ' created.'); | ||
if(options.report) { | ||
helper.minMaxInfo(min, max, options.report); | ||
} | ||
if (options.banner) { | ||
min = options.banner + grunt.util.linefeed + min; | ||
} | ||
grunt.file.write(file.dest, min); | ||
grunt.log.writeln('File ' + chalk.cyan(file.dest) + ' created: ' + maxmin(max, min, options.report === 'gzip')); | ||
}); | ||
}); | ||
var minifyCSS = function(source, options) { | ||
try { | ||
return new CleanCSS(options).minify(source); | ||
} catch (e) { | ||
grunt.log.error(e); | ||
grunt.fail.warn('css minification failed.'); | ||
} | ||
}; | ||
}; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8098
53
120
1
+ Addedmaxmin@~0.1.0
+ Addedbuffer-from@1.1.2(transitive)
+ Addedconcat-stream@1.6.2(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddeep-equal@0.0.0(transitive)
+ Addeddefined@0.0.0(transitive)
+ Addedgzip-size@0.1.1(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedjsonify@0.0.1(transitive)
+ Addedmaxmin@0.1.0(transitive)
+ Addedpretty-bytes@0.1.2(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedtape@0.2.2(transitive)
+ Addedtypedarray@0.0.6(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedzlib-browserify@0.0.3(transitive)
- Removedgrunt-lib-contrib@~0.6.0
- Removedgrunt-lib-contrib@0.6.1(transitive)
- Removedzlib-browserify@0.0.1(transitive)