Skip to content
PluginStats

vite-css-modules weekly downloads statistics

By privatenumber (2 listings) · npm · Vite plugins

Vite plugin for correct CSS Modules behavior

View on npm Fresh · Oct 17, 2026

vite-css-modules has 50,223 recorded weekly downloads on npm, a decrease of 22.4% over the past 30 days.

It ranks #562 of 2,251 tracked npm listings by weekly downloads.

Over 90 days, weekly downloads changed by -39.3%.

PluginStats has 543 daily observations since Apr 23, 2025; the latest is from Oct 17, 2026.

Weekly downloads
50,223
Official API · Oct 17, 2026
7-day growth
-45.3%
-41.6K weekly downloads
30-day growth
-22.4%
-14.5K weekly downloads
90-day growth
-39.3%
-32.6K weekly downloads
Rank
#562
Among tracked npm listings

About vite-css-modules

vite-css-modules

Vite plugin to fix broken CSS Modules handling.

→ Play with a demo on StackBlitz

[!NOTE] We're working to integrate this fix directly into Vite (PR #16018). Until then, use this plugin to benefit from these improvements now.

Why use this plugin?

Have you encountered any of these Vite CSS Module bugs? They're happening because Vite's CSS Modules implementation delegates everything to postcss-modules, creating a black box that Vite can't see into.

This plugin fixes these issues by properly integrating CSS Modules into Vite's build pipeline.

The bugs this fixes

1. PostCSS plugins don't apply to composes dependencies

When you use composes to import classes from another CSS file, Vite's PostCSS plugins never process the imported file. This means your PostCSS transformations, auto-prefixing, or custom plugins are silently skipped for dependencies.

What happens in Vite: • style.module.css gets processed by PostCSS ✓ • utils.css does NOT get processed by PostCSS ✗ • Your PostCSS plugin never sees utils.css because postcss-modules bundles it internally

With this plugin: • Both files go through your PostCSS pipeline correctly

Vite issue #10079, #10340 | Test case

2. Shared classes get duplicated in your bundle

When multiple CSS Modules compose from the same utility file, the utility's styles get bundled multiple times. This increases bundle size and can cause style conflicts.

Example:

What happens in Vite:

With this plugin:

Vite issue #7504, #15683 | Test case

3. Missing composes classes fail silently

If you typo a class name in composes, Vite doesn't error. Instead, it outputs undefined in your class names, breaking your UI with no warning.

Example:

What happens in Vite:

With this plugin:

Vite issue #16075 | Test case

4. Can't compose between CSS and SCSS

Trying to compose from SCSS/Sass files causes syntax errors because postcss-modules tries to parse SCSS as plain CSS.

Example:

What happens in Vite:

With this plugin: • Works correctly because each file goes through its proper preprocessor first

Vite issue #10340 | Test case

5. HMR doesn't work properly

Changing a CSS Module file causes a full page reload instead of a hot update, losing component state.

What happens in Vite: • Full page reload on CSS Module changes

With this plugin: • CSS Module changes update instantly without losing component state

Vite issue #16074 | Test case

6. Reserved JavaScript keywords break exports

Using JavaScript reserved keywords as class names (like .import, .export) generates invalid JavaScript code.

Example:

What happens in Vite:

With this plugin: • Properly handles reserved keywords in class names

Vite issue #14050 | Test case

Install

Setup

In your Vite config file, add the patchCssModules() plugin to patch Vite's CSS Modules behavior:

This patches your Vite to handle CSS Modules in a more predictable way.

Configuration

Configuring the CSS Modules behavior remains the same as before.

Read the Vite docs to learn more.

Type checking & navigation for CSS Modules

This plugin can generate type definition (.d.ts) files for CSS Modules, providing autocomplete and type checking for class names. For example, importing style.module.css will create a style.module.css.d.ts next to it:

Go to CSS Definition

Add declarationMap to include inline source maps in the generated .d.ts files:

This enables "Go to Definition" (F12 / Cmd+Click in VS Code) to jump from a CSS class name in TypeScript directly to where it's defined in the CSS file. Without declaration maps, "Go to Definition" lands on the generated .d.ts — a machine-generated file with no useful context.

When not explicitly set, declarationMap auto-detects from tsconfig.json's compilerOptions.declarationMap.

API

patchCssModules(options)

exportMode

• Type: 'both' | 'named' | 'default' • Default: 'both'

Specifies how class names are exported from the CSS Module:

• both: Exports class names as both named and default exports. • named: Exports class names as named exports only. • default: Exports class names as a default export only (an object where keys are class names).

generateSourceTypes

• Type: boolean • Default: false

Generates a .d.ts file next to each CSS Module with type definitions for the exported class names.

declarationMap

• Type: boolean • Default: Auto-detected from tsconfig.json's compilerOptions.declarationMap

Generates inline declaration source maps in .d.ts files, enabling "Go to Definition" to navigate from TypeScript to CSS source. Requires generateSourceTypes to be enabled.

[!TIP] Source maps are always inlined rather than emitted as separate .d.ts.map files. Since .d.ts files are generated in-place next to your CSS source, external map files would pollute the source directory. The size overhead of inlining is negligible for typical CSS modules.

CLI

Generate TypeScript declarations for CSS Modules without running a build.

The CLI expects a vite.config.* file in the current working directory and uses that one config for every matched file.

With no globs, the CLI defaults to:

and searches under the resolved Vite root.

When you pass globs explicitly, they are resolved from the current working directory instead.

Run it from the same cwd you would use for vite, or pass --config to point at a specific config file. Use --mode when your Vite config depends on the active mode.

The CLI requires patchCssModules() in your Vite config and reads its options (exportMode, declarationMap) along with Vite's css.modules settings.

Flags

| Flag | Description |

| --config | Use a specific vite.config.* file | | --mode | Set the Vite mode used when loading config | | --silent, -s | Suppress success output (errors still print to stderr) |

Examples

FAQ

What issues does this plugin address?

Vite delegates bundling each CSS Module to postcss-modules, leading to significant problems:

1. CSS Modules not integrated into Vite's build…

Description from the npm listing.

  • vite
  • plugin
  • vite-plugin
  • css modules
  • patch

Where vite-css-modules sits in the listing

Each band is one page of 20. Weekly downloads on a log 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.

All npm2,248 listings · 113 pages · page 29, #2 (overall #562)
All npm: every listing in weekly downloads order
PNG SVG
Vite plugins250 listings · 13 pages · page 5, #5 (overall #85)
Vite plugins: every listing in weekly downloads order
PNG SVG

Charts

Images: 30d · 1y · all time · 1600×900 dark

Adoption over time

vite-css-modules weekly downloads on npm, last 90 days: 50,223 weekly downloads as of Oct 17, 2026, -39.3% over 90 days.vite-css-modulesWeekly downloads on npm · Last 90 days50,223downloads / week-39.3% over 90 days020K40K60K80K100K120KJul 19Aug 3Aug 18Sep 2Sep 17Oct 2Oct 17downloads / weekobservedarchived (Internet Archive)no observationsJul 20, 2026 – Oct 17, 2026 · 90 observations · Updated Oc…pluginstats.com
vite-css-modules weekly downloads on npm, last 90 days: 50,223 weekly downloads as of Oct 17, 2026, -39.3% over 90 days.
PNG SVG

7/30/90-day growth

vite-css-modules weekly downloads growth on npm: -45.3% over 7 days, -22.4% over 30 days, -39.3% over 90 days.vite-css-modulesWeekly downloads growth on npm50,223downloads / week now7-day growth-41,624 weekly downloads-45.3%30-day growth-14,462 weekly downloads-22.4%90-day growth-32,560 weekly downloads-39.3%Growth vs. nearest observation to each baseline date · Updated Oct 17, 2026pluginstats.com
vite-css-modules weekly downloads growth on npm: -45.3% over 7 days, -22.4% over 30 days, -39.3% over 90 days.
PNG SVG

Ranking history

vite-css-modules npm ranking history: currently #562 (by weekly downloads).vite-css-modulesnpm ranking · by weekly downloads · Last 90 days#562current rank#150#200#250#300#350#400#450#500#550#600Jul 20Aug 4Aug 19Sep 3Sep 18Oct 3Oct 18rankOct 17, 2026 – Oct 18, 2026 · 2 observations · Updated Oct 17, 2026pluginstats.com
vite-css-modules npm ranking history: currently #562 (by weekly downloads).
PNG SVG

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.

Recent observations

Full history (543)
Recent weekly downloads observations for vite-css-modules
Date (UTC)Weekly downloadsChange vs. previous
50,223-3.9K
54,118+5.5K
48,619-21.2K
69,823-22.2K
92,0620
92,062+156
91,906+59
91,847-773
92,620+3
92,617+41
92,576-977
93,553-20.8K
114,381+6.1K
108,265—

Similar npm Vite plugins plugins

Data 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-css-modules. First seen Oct 16, 2026; last successful collection Oct 18, 2026. See the methodology.