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 ...

Get Bootstrap 4 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.