Rollup plugin providing seamless integration with PostCSS. The current stable version is v4.0.2 (released Nov 2021, engines node >=10). It requires PostCSS 8.x as a peer dependency. Key differentiators: supports CSS modules, automatic PostCSS config loading, inject CSS into <head> or extract to file, and works with Sass, Less, Stylus via dependencies. Breaking change in v3: only supports Rollup v2, and extract path must be absolute. v4 upgraded to PostCSS 8. Also provides TypeScript types.
npm install rollup-plugin-postcssVerified import paths — ran on the pinned version, not inferred.
Basic Rollup config using rollup-plugin-postcss with Autoprefixer, CSS modules, extraction, and minimization.
Use absolute paths for extract option, or stay on v2.x if using Rollup 1.x.
Upgrade PostCSS to version 8.x. Update any PostCSS plugins to be compatible with PostCSS 8.
When upgrading to v3+, change extract option to an absolute path using path.resolve().
Ensure the desired Sass implementation is installed; to use node-sass, uninstall dart-sass.
Set autoModules: false to disable automatic CSS modules, or adjust file naming conventions.
Use path.resolve(__dirname, 'dist/styles.css') instead of 'dist/styles.css'.
Update PostCSS to 8.x and ensure all PostCSS plugins are compatible.
Run npm install rollup-plugin-postcss --save-dev.
Provide at least one PostCSS plugin in the plugins array, even if empty.