Identify unused CSS classes via PurgeCSS and propose a configuration that's safe in the presence of dynamically constructed class names.
Runs PurgeCSS over a build's CSS output and source files, identifies unused classes, and proposes a safe purgecss.config.js — including an explicit safelist for class names constructed at runtime via string concatenation or template literals.
css_path: the built CSS file (e.g., dist/styles.css).source_globs: array of source file globs (['src/**/*.{js,ts,jsx,tsx,html}']).safelist_extra: classes to never purge regardless.npx purgecss --css <css_path> --content <source_globs> --output /tmp/purged/ and capture the size delta.source_globs: detect \btn-${x}`, 'class-' + name, clsx(...), cx(...)` patterns. Extract literal prefixes as candidate safelist entries.className={\...${...}...`}` with non-trivial interpolation flags the surrounding component for safelisting.purgecss.config.js:
module.exports = {
content: <source_globs>,
safelist: { standard: [...explicit...], greedy: [/^prefix-/...] },
defaultExtractor: content => content.match(/[A-Za-z0-9-_:/]+/g) || [],
};
:root variables, keyframes referenced by safelisted classes, and Tailwind dark: / hover: variants explicitly to the safelist.gzip -c <file> | wc -c.Two files: purgecss.config.js (the proposed config) and css-shrink-report.md (table with: original size, purged size, gzipped sizes, list of safelisted patterns, count of removed classes). Stdout prints percent saved.
Build the app with the new config and visually compare against the previous build using a screenshot diff (playwright's expect(page).toHaveScreenshot()); pixel diff above 0.1% means a safelist gap. Re-run on a representative set of dynamic UI states (modals open, tabs switched). If gzipped size grows after purge (unlikely but possible with verbose safelist), revert.
md:hover:bg-blue-500): use the defaultExtractor shown above; default extractor strips colons.safelist_extra to be populated, else risk visible breakage.Other publishers' experience with this skill. Self-rating is blocked.
Sign in and publish to the registry to leave a rating.
No ratings yet. Be the first.
Same domains or capabilities as amitte/css-bundle-shrinker.
Write five Google Ads responsive search ad copy variants from a product description and audience — each fits headline length and includes a distinct CTA.
Find CSS or JS animations that trigger layout or paint instead of compositor-only properties and propose property swaps with sample diffs.
Read a Lighthouse or CrUX report and narrate LCP, CLS, and INP scores into a prioritized fix plan with concrete code suggestions.
Tighten a Content-Security-Policy by stripping wildcards and verifying the result against actual page resource loads observed in browser logs.
Audit a Tailwind config for color contrast in dark mode and flag every text-on-background pair below WCAG AA thresholds.
Walk a React component tree and identify subtrees not covered by an Error Boundary, suggesting placement points for new boundaries.