Socket
Socket
Sign inDemoInstall

grunt-contrib-cssmin

Package Overview
Dependencies
Maintainers
4
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-contrib-cssmin - npm Package Compare versions

Comparing version 0.8.0 to 0.9.0

4

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc