A Vite plugin (v1.1.4, last updated 2024) that enables CSS Modules for all CSS/SCSS files without requiring the .module.css naming convention. Primarily designed for migrating legacy React projects to Vite where files are not named with the .module.css pattern. Supports custom include/exclude patterns via regex or function, and per-file opting out with ?global query. Lightweight, TypeScript-compatible, but has minimal documentation and no tests.
npm install vite-plugin-setting-css-moduleVerified import paths — ran on the pinned version, not inferred.
Basic setup enabling CSS Modules for all CSS/SCSS files in a Vite + React project.
Use exclude option to exclude global CSS files, e.g., exclude: /.*\.global\.css$/
Use function for more control: include: (fileName) => fileName.endsWith('.scss')No fix needed, but be aware that support may be limited.
Use: import vitePluginSettingCssModule from 'vite-plugin-setting-css-module'
Ensure you call the plugin as a function: plugins: [vitePluginSettingCssModule()]
Add the exclude option: exclude: /.*\.global\.css$/
No dependency data recorded yet.