Registry / web-framework / vite-plugin-purgecss-updated-v5

vite-plugin-purgecss-updated-v5

JSON →
library1.2.7jsnpmunverified

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-v5
INSTALL
IMPORT
SIG · VITE-PLUGIN-PURGEC
V
vite-plugin-purgecss-updated-v5
web-frameworkjavascriptv1.2.7
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default export (pluginPurgeCss)
✓ import pluginPurgeCss from 'vite-plugin-purgecss-updated-v5'
✗ const pluginPurgeCss = require('vite-plugin-purgecss-updated-v5')
Package is ESM-only; named exports may not be available. Default import is the plugin function.
Options type
✓ import type { UserDefinedOptions } from 'vite-plugin-purgecss-updated-v5'
Type import for PurgeCSS options, available since v1.0.0
Plugin registration
✓ plugins: [pluginPurgeCss({ variables: true })]
✗ plugins: [pluginPurgeCss({ variables: 'true' })]
Options object is passed directly; variables is a boolean, not a string.

Sets up PurgeCSS with Vite, safelisting elements and regex patterns, enabling variable purging, and disabling font-face/keyframe removal.

// vite.config.ts import { defineConfig } from 'vite'; import pluginPurgeCss from 'vite-plugin-purgecss-updated-v5'; export default defineConfig({ plugins: [ pluginPurgeCss({ safelist: { standard: ['body', 'html'], deep: [/^my-/], greedy: [/^my-/], }, variables: true, fontFace: false, keyframes: false, }), ], });
Debug
Known issues
gotchaThe `content` and `css` options bypass Vite's build pipeline. Do not pass files requiring Vite processing (e.g., .vue, .svelte) to these options.
fix
Use the default automatic content detection; only provide raw strings or already-processed file paths.
affects: *
deprecatedPackage name differs from original '@mojojoejo/vite-plugin-purgecss' which may cause confusion. Ensure correct import path.
fix
Use 'vite-plugin-purgecss-updated-v5' as shown in documentation.
affects: >=1.0.0
breakingPlugin expects Vite 5+ but also supports older versions as peer (3, 4). Incorrect peer resolution may cause silent failures.
fix
Check your Vite version and ensure it matches the peer range: '^3 || ^4 || ^5 || ^6 || ^7 || ^8'.
affects: >=1.0.0
gotchaCSS Modules are automatically supported via postcss-modules, but custom extractors may interfere with hashed class name detection.
fix
Avoid overriding `defaultExtractor` when using CSS Modules; use the built-in handling instead.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'vite-plugin-purgecss-updated-v5'
Package not installed or incorrect import path.
fix
Run: npm install --save-dev vite-plugin-purgecss-updated-v5
TypeError: pluginPurgeCss is not a function
Using CommonJS require() instead of ESM import.
fix
Use: import pluginPurgeCss from 'vite-plugin-purgecss-updated-v5'
ERROR: Unused CSS - expected classes removed
PurgeCSS removed classes that are dynamically added, e.g., via JavaScript.
fix
Add safelist options to preserve those classes: safelist: { standard: ['dynamic-class'] }
Upgrade
Version history
1.2.7latest on npm
Audit
Dependencies
viteoptionalPeer dependency; plugin requires Vite to function
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
2
Resources
vite-plugin-purgecss-updated-v5 — npm install vite-plugin-purgecss-updated-v5 · libregistry