With GruntJS, as we saw in the last post, we can minify javascript files, the next in line is the CSS files.
I have updated the Github repo for using CSS along with Javascript files.
The basic setup is not different from javascript setup. Here we have to use
grunt-contrib-cssmin
The confusing part is, for minification we have a lot of options in NPM, and one of them is
grunt-contrib-mincss
So at first I was confused and it did not work for me. Seems like “mincss” is old and have not been updated for a long time. So I am with “cssmin” and that just works.
As usual, install cssmin locally, with
npm install grunt-contrib-cssmin
A note is, if you have “package.json” and “Gruntfile.js” file in the same location, take those files somewhere else while installing new packages from NPM, else it throws some errors. Once installation is complete, bring those files back and that should work as it was before.
Happy grunting.