Generates typed definitions for css modules using typed-css-modules.
The plugin will set the vite config field css.modules.localsConvention
to camelCaseOnly
and sets the camelCase
option in typed-css-modules.
Using the vite dev server watcher, any time a [name].module.css
file is edited a [name].module.css.d.ts
file will be rewritten.
npm install vite-plugin-typed-css-modules
// vite.config.js
import typedCssModulesPlugin from "vite-plugin-typed-css-modules";
/** @type {import('vite').UserConfig} */
const config = {
plugins: [typedCssModulesPlugin()],
};
export default config;