How it works...

This process is quite simple. You just add grunt-uncss to other Grunt plugins you are already using in your build process. In step 3, we specified options related to UnCSS in our Gruntfile.js. We specified the source folder to look at HTML files (and, thus, the CSS classes and ID's that these HTML files reference), and then the destination folder, where we will output the minified CSS files, stripped from unused declarations.

There are multiple ways to work with Grunt plugins in your workflow, but it is important to note one thing when working with preprocessors, or, in the case of Bootstrap 4, when working with Sass. All the Grunt tasks related to processing scss files can be thought of as the preprocessing step of our workflow. ...

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.