A Rollup plugin that wraps rollup-plugin-postcss with built-in CSS Modules and TypeScript support. Stable version 2.1.1, released September 2023. Provides automatic generation of .d.ts files for CSS modules, enabling type-safe imports in TypeScript projects. The only maintained fork with TypeScript integration after rollup-plugin-postcss v2 dropped CSS Modules support. Differentiator: handles named exports with class name mangling (e.g., hyphenated names become camelCase with $ prefix) and generates default export objects alongside named exports.
npm install rollup-plugin-postcss-modulesVerified import paths — ran on the pinned version, not inferred.
Shows basic Rollup config with CSS modules, TypeScript definition generation, and autoprefixer.
Upgrade postcss to v8 and ensure rollup-plugin-postcss peer dependency is satisfied.
Use default export object for dynamic access, or enable camelCase option in postcss-modules options.
Move PostCSS plugins to modules.plugins rather than top-level plugins.
Ensure .css.d.ts files are not edited manually; consider version control exclusion.
Run npm install rollup-plugin-postcss --save-dev
Correct usage: plugins: [postcss({...})] (call the imported function)Suppress lint rule or use default export (import style from './file.css') and access via style.className.