UnCSS Setup Jekyll Bootstrap 4
gulp.task('sass:production', function() {
return gulp.src(config.sass.src)
.pipe(sass({
includePaths: config.sass.sassPaths,
outputStyle: 'expanded'
})
.on('error', sass.logError))
.pipe(uncss({
html: glob.sync(config.optimize.uncss.src),
ignore: [
/\.fade/,
/\.modal/,
/\.affix/,
/\.tooltip/,
/\.popover/,
/\.collaps/,
/\.carousel-inner/,
/\.open/,
/\.in/,
/\.flipped/,
/\.waves/,
/(#|\.)(is-)/,
/(#|\.)(has-)/,
/(#|\.)(js-)/,
// sample regex to ignore '.active' class
/\.\bactive\b/
],
ignoreSheets: [
// ignoreSheets: sample regex to ignore Google fonts
/fonts.googleapis/
]
}))
.pipe(prefix({
browsers: ['last 2 versions', 'ie >= 9']
}))
.pipe(minifycss(config.optimize.css.options))
.pipe(gulp.dest(config.sass.prod))
});
// More importantly, this invocation of UnCSS reads the stylesheets linked in index.html to find the correct CSS-file, then processes it.