Whitelist selectors on Purgecss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Purgecss = require('purgecss') | |
var purgecss = new Purgecss({ | |
content: ['**/*.html'], | |
css: ['**/*.css'] | |
}) | |
var purgecssResult = purgecss.purge() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class"alert alert-<?php echo $type; ?>" ><?php echo $message; ?></div> | |
// A prettier version using Laravel-Blade | |
<div class="aler alert-{{ $type }}">{{ $message }}</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.alert { | |
color: white; | |
} | |
.alert-error { | |
background: red; | |
} | |
.alert-success { | |
background: green; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const purgecss = new Purgecss({ | |
content: [], // content | |
css: [], // css | |
whitelist: ['alert-success', 'alert-success'] | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const purgecss = new Purgecss({ | |
content: [], // content | |
css: [], // css | |
whitelistPatterns: [/alert/] | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* purgecss ignore */ | |
.alert-success { | |
background: green; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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