grunt-contrib-cssmin
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -7,6 +7,14 @@ # Usage Examples | ||
files: { | ||
"path/to/output.css": ["path/to/input_one.css", "path/to/input_two.css"] | ||
'path/to/output.css': ['path/to/input_one.css', 'path/to/input_two.css'] | ||
} | ||
}, | ||
with_banner: { | ||
options: { | ||
banner: '/* My minified css file */' | ||
}, | ||
files: { | ||
'path/to/output.css': ['path/to/**/*.css'] | ||
} | ||
} | ||
} | ||
``` |
@@ -41,2 +41,19 @@ /* | ||
} | ||
}, | ||
with_banner: { | ||
options: { | ||
banner: '/* module name - my awesome css banner */' | ||
}, | ||
files: { | ||
'tmp/with-banner.css': ['test/fixtures/input_one.css', 'test/fixtures/input_two.css'] | ||
} | ||
}, | ||
remove_first_comment: { | ||
options: { | ||
banner: '/* custom banner */', | ||
keepSpecialComments: 0 | ||
}, | ||
files: { | ||
'tmp/remove_first_comment.css': ['test/fixtures/input_bannered.css'] | ||
} | ||
} | ||
@@ -43,0 +60,0 @@ }, |
{ | ||
"name": "grunt-contrib-cssmin", | ||
"description": "Compress CSS files.", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"homepage": "https://github.com/gruntjs/grunt-contrib-cssmin", | ||
@@ -35,3 +35,3 @@ "author": { | ||
"devDependencies": { | ||
"grunt-contrib-jshint": "~0.1.1", | ||
"grunt-contrib-jshint": "~0.2.0", | ||
"grunt-contrib-nodeunit": "~0.1.2", | ||
@@ -38,0 +38,0 @@ "grunt-contrib-clean": "~0.4.0", |
@@ -16,3 +16,3 @@ # grunt-contrib-cssmin [![Build Status](https://secure.travis-ci.org/gruntjs/grunt-contrib-cssmin.png?branch=master)](http://travis-ci.org/gruntjs/grunt-contrib-cssmin) | ||
One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript: | ||
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript: | ||
@@ -33,3 +33,17 @@ ```js | ||
Files are compressed with [clean-css](https://github.com/GoalSmashers/clean-css). | ||
### Options | ||
#### banner | ||
Type: `String` | ||
Default: `null` | ||
Prefix the compressed source with the given banner, with a linebreak inbetween. | ||
#### keepSpecialComments | ||
Type: `String` `Number` | ||
Default: `'*'` | ||
To keep or remove special comments, exposing the underlying option from [clean-css](https://github.com/GoalSmashers/clean-css).. `'*'` for keeping all (default), `1` for keeping first one, `0` for removing all. | ||
### Usage Examples | ||
@@ -41,4 +55,12 @@ | ||
files: { | ||
"path/to/output.css": ["path/to/input_one.css", "path/to/input_two.css"] | ||
'path/to/output.css': ['path/to/input_one.css', 'path/to/input_two.css'] | ||
} | ||
}, | ||
with_banner: { | ||
options: { | ||
banner: '/* My minified css file */' | ||
}, | ||
files: { | ||
'path/to/output.css': ['path/to/**/*.css'] | ||
} | ||
} | ||
@@ -51,2 +73,3 @@ } | ||
* 2013-03-09 v0.4.2 Add banner option Support clean-css keepSpecialComments | ||
* 2013-02-16 v0.4.1 Update clean-css dependency to ~0.10.0 | ||
@@ -65,2 +88,2 @@ * 2013-02-14 v0.4.0 First official release for Grunt 0.4.0. | ||
*This file was generated on Mon Feb 18 2013 08:37:57.* | ||
*This file was generated on Sun Mar 10 2013 19:09:35.* |
@@ -15,2 +15,3 @@ /* | ||
grunt.registerMultiTask('cssmin', 'Minify CSS files', function() { | ||
var options = this.options(); | ||
this.files.forEach(function(f) { | ||
@@ -29,6 +30,9 @@ var max = f.src.filter(function(filepath) { | ||
var min = minifyCSS(max); | ||
var min = minifyCSS(max, options); | ||
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); | ||
@@ -41,5 +45,5 @@ grunt.log.writeln('File ' + f.dest + ' created.'); | ||
var minifyCSS = function(source) { | ||
var minifyCSS = function(source, options) { | ||
try { | ||
return require('clean-css').process(source); | ||
return require('clean-css').process(source, options); | ||
} catch (e) { | ||
@@ -46,0 +50,0 @@ grunt.log.error(e); |
@@ -15,2 +15,11 @@ 'use strict'; | ||
}, | ||
with_banner: function(test) { | ||
test.expect(1); | ||
var expect = grunt.file.read('test/expected/with-banner.css'); | ||
var result = grunt.file.read('tmp/with-banner.css'); | ||
test.equal(expect, result, 'should concat, minify and prefix banner'); | ||
test.done(); | ||
}, | ||
empty: function(test) { | ||
@@ -22,3 +31,12 @@ test.expect(1); | ||
test.done(); | ||
}, | ||
remove_first_comment: function(test) { | ||
test.expect(1); | ||
var expect = grunt.file.read('test/expected/input_bannered.css'); | ||
var result = grunt.file.read('tmp/remove_first_comment.css'); | ||
test.equal(expect, result, 'should minify and replace banner'); | ||
test.done(); | ||
} | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
13213
22
162
85
0