Skip to content

Instantly share code, notes, and snippets.

@jeffochoa jeffochoa/1.js Secret
Last active Apr 24, 2019

Embed
What would you like to do?
Whitelist selectors on Purgecss
var Purgecss = require('purgecss')
var purgecss = new Purgecss({
content: ['**/*.html'],
css: ['**/*.css']
})
var purgecssResult = purgecss.purge()
<div class"alert alert-<?php echo $type; ?>" ><?php echo $message; ?></div>
// A prettier version using Laravel-Blade
<div class="aler alert-{{ $type }}">{{ $message }}</div>
.alert {
color: white;
}
.alert-error {
background: red;
}
.alert-success {
background: green;
}
const purgecss = new Purgecss({
content: [], // content
css: [], // css
whitelist: ['alert-success', 'alert-success']
})
const purgecss = new Purgecss({
content: [], // content
css: [], // css
whitelistPatterns: [/alert/]
})
/* purgecss ignore */
.alert-success {
background: green;
}
const mix = require('laravel-mix');
require('laravel-mix-purgecss');
// ...
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css')
.purgeCss();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.