Protect dynamically-built class names from purging — with regex safelists.
Syntax#
nakshora.config.js
export default {
safelist: [
'bg-red-500',
{ pattern: /^bg-(blue|green)-(400|500)$/, variants: ['hover'] },
],
};Details & defaults#
Classes the scanner cannot see (built at runtime, toggled from a database) must be safelisted or they get purged. Patterns accept regex + variant lists. Rule of thumb: if you safelist more than ~50 classes, your content globs are probably wrong.
Worked examples#
- Runtime status colors:
/^bg-(red|amber|green)-500$/ - Server-rendered alerts whose classes come from a database
Related options#
See the configuration/index|configuration hub for the full option table, and api/theme-resolution|theme resolution for how options merge.
