vite-plugin-optimize-css-modules weekly downloads statistics
By simonwep · npm · Vite plugins
Mangles the classnames generated by postcss-modules in vite
vite-plugin-optimize-css-modules has 84,897 recorded weekly downloads on npm, an increase of 143% over the past 30 days, ranking #663 of 3,247 tracked listings.
About vite-plugin-optimize-css-modules
Setup
This plugin requires vite of v3 or greater. It only makes sense to use if you're using css modules.
$ npm install --save-dev vite-plugin-optimize-css-modules
In your vite.config.ts simply add the plugin:
import { optimizeCssModules } from 'vite-plugin-optimize-css-modules';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
optimizeCssModules()
]
})
And that's it. When running vite build your generated CSS should be significantly smaller.
Benchmarks
Benchmarks are done against bootstrap and materialize.css assuming all the classes are used as css modules. The benchmark code is located in the benchmarks directory.
Run them by building the plugin via npm run build and then running npm run benchmarks.
The results below are from a MacBook Air M2 with node v22.8.0, ran on the 31th December 2024.
| Input | Build Time | Gzip Size | Brotli Size |
|---|---|---|---|
| bootstrap-5.0.2.module.css | 525ms (-94.06% / -8311ms) | 21.3 kB (-26.53% / -7.69 kB) | 21.3 kB (-27.54% / -6 kB) |
| materialize-1.0.0.module.css | 572ms (-92.59% / -7156ms) | 20.1 kB (-19.70% / -4.93 kB) | 20.1 kB (-21.33% / -4.3 kB) |
How does it work?
By default, when using css modules, you end up with hashes or other long class-names in your bundled css files:
@keyframes _close-card_pzatx_1 {
/* ...css */
}
._card_pzatx_32 {
/* ...css */
}
._back_pzatx_49 ._content_pzatx_70 ._close_pzatx_74 {
/* ...css */
}
By using this module, the smalles possible classname will be used for each "id":
@keyframes a {
/* ...css */
}
.v {
/* ...css */
}
.c .s .w {
/* ...css */
}
Description from the npm listing.
- vite
- vite-plugin
- css-modules
- css
- minify
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (591)Similar npm Vite plugins plugins
All 20 vite-plugin-optimize-css-modules alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/vite-plugin-optimize-css-modules. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.