In this recipe, we'll make use of the contrib-cssmin (0.10.0)
plugin to decrease the size of some CSS documents by minifying them.
In this example, we'll work with the basic project structure we created in the Installing Grunt on a project recipe in Chapter 1, Getting Started with Grunt. Be sure to refer to it if you are not yet familiar with its contents.
The following steps take us through creating a sample CSS document and configuring a task that minifies it.
We'll start by installing the package that contains the
contrib-cssmin
plugin as per the instructions provided in the Installing a plugin recipe in Chapter 1, Getting Started with Grunt.Then, we'll create a simple CSS document called
style.css
in thesrc
directory, which we'd like to minify, and provide it with the following contents:body { /* Average body style */ background-color: #ffffff; color: #000000; /*! Black (Special) */ }
Now, we'll add the following
cssmin
task to our configuration...