Cleaning up unused CSS with UnCSS and Grunt
In this recipe, we will continue with CSS optimization. In the preceding recipe, we cherry-picked scss
partials by simply commenting out those that were not used. For example, we did not use the alert component, so we commented out its Sass @include
command in main.scss
.
This time, the approach is different. We will use pretty much the same code in our main.scss
file in this recipe; however, this time, we will not comment out anything. In other words, we will include all the partials. Then, we'll set up our Grunt task runner with another Grunt plugin, namely, the grunt-uncss
plugin. Running the plugin command through our console, we will then take the compiled CSS file and clean it up by removing the unused CSS declarations from it, which will significantly reduce its file size.
Getting ready
To begin with, let's preview the completed recipe. Navigate to chapter9/complete/app/
and run harp server
in your console. Next, open your browser and point...