Vite plugin that integrates PurgeCSS to remove unused CSS from production bundles. Version 1.2.7 supports Vite 3 through 8 as peer dependencies, making it future-proof for Vite 5+ projects. TypeScript types included. Key differentiators: automatic detection of CSS modules hashed class names, supports PurgeCSS variables option, and passes Vite chunks as content automatically, reducing configuration overhead.
npm install vite-plugin-purgecss-updated-v5Verified import paths — ran on the pinned version, not inferred.
Sets up PurgeCSS with Vite, safelisting elements and regex patterns, enabling variable purging, and disabling font-face/keyframe removal.
Use the default automatic content detection; only provide raw strings or already-processed file paths.
Use 'vite-plugin-purgecss-updated-v5' as shown in documentation.
Check your Vite version and ensure it matches the peer range: '^3 || ^4 || ^5 || ^6 || ^7 || ^8'.
Avoid overriding `defaultExtractor` when using CSS Modules; use the built-in handling instead.
Run: npm install --save-dev vite-plugin-purgecss-updated-v5
Use: import pluginPurgeCss from 'vite-plugin-purgecss-updated-v5'
Add safelist options to preserve those classes: safelist: { standard: ['dynamic-class'] }