A Rollup plugin providing support for standard CSS modules with import attributes (type: 'css'). Current stable version is 0.2.0, with no frequent release cadence yet. Key differentiators: it supports both transforming CSS modules into JavaScript that exports CSSStyleSheet instances (for browsers without native CSS module support) and bundling modules into a single CSS file with @supports sheet() wrappers for native support. It requires Rollup 4+. The plugin is lightweight, has no options besides bundledSheet, and ships TypeScript types.
npm install rollup-plugin-css-modulesVerified import paths — ran on the pinned version, not inferred.
Basic Rollup config using cssModules() with bundledSheet option to emit a single CSS file.
Ensure your CSS imports include the attribute: import styles from './styles.css' with { type: 'css' };Use import syntax or dynamic import(). For CommonJS projects, consider using rollup-plugin-css-modules with ESM config.
If your toolchain breaks because of unknown @supports, consider using the non-bundled mode (without bundledSheet option).
Switch to import { cssModules } from 'rollup-plugin-css-modules' in an ESM context, or use dynamic import.Use import styles from './file.css' with { type: 'css' }; and ensure plugin is added to config.Use import { cssModules } from 'rollup-plugin-css-modules'.