css-condense grunt plugin
grunt-cssc is a grunt plugin which allows the use of css-condense module within grunt.
This plugin requires Grunt
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
Install grunt-cssc module via npm in your project directory
npm install grunt-cssc --save-dev
The "cssc" task
It is a multi task which means you can process to further executions in the same grunt declaration.
In your project's Gruntfile, add a section named
cssc to the data object passed into
For each set of instruction, you can specify an Option object wich will define the type of compression you need for your specific set. If no options object is defined in your set of instruction, the default compression options will occur.
Each option is based upon css-condense, here is the list :
- sortSelectors (Boolean, Default true) : if true, sort css files by selectors
- lineBreaks (Boolean, Default true) : if true, trim line breaks
- sortDeclarations (Boolean, Default true) : if true, sort css selectors by declarations
- consolidateViaDeclarations (Boolean, Default false) : if true, merge by declarations
- consolidateViaSelectors (Boolean, Default true) : if true, merge by selectors
- consolidateMediaQueries (Boolean, Default true) : if true, merge by mediaqueries
- compress (Boolean, Default true) : if true, compress the file
- sort (Boolean, Default false) : if false, turn off sorting
- safe (Boolean, Default false) : if true, avoid the use of consolidate
In this example, custom options are used to do something else with whatever else. So if the
testing file has the content
Testing and the
123 file had the content
1 2 3, the generated result in this case would be
Testing: 1 2 3 !!!
- 2013/04/30 - v0.2.6 - grunt 0.4.1 grunt-cssc plugin version.
- 2012/12/11 - v0.1.0 - Initial release.
Copyright (c) 2012 Étienne Samson for "Mediapart". Licensed under the Open Source Initiative MIT license.