A Vite plugin that removes unused CSS from the production build by integrating PurgeCSS. Version 0.2.13, actively maintained with occasional updates. Fork of vite-plugin-html-purgecss, it scans both HTML and JS output to find CSS class references, making it compatible with JavaScript frameworks like SvelteKit. Unlike PurgeCSS CLI, it works seamlessly within Vite's build pipeline without extra configuration. Lightweight and easy to set up, it accepts all standard PurgeCSS options including safelist for preserving dynamic classes. Supports TypeScript with bundled type definitions.
npm install vite-plugin-purgecssVerified import paths — ran on the pinned version, not inferred.
Basic setup of vite-plugin-purgecss in Vite config with safelist option.
Add potentially dynamic classes to the safelist manually.
Refer to this plugin's documentation rather than the original.
Use safelist or allow-duplication options to preserve expected classes.
Use 'import htmlPurge from 'vite-plugin-purgecss''.
Ensure you are calling the default export as a function: htmlPurge({...}).Run 'npm install vite-plugin-purgecss' and check the import path.
Add missing classes or patterns to the safelist option.