A lightweight Rollup plugin (v4.2.1) for importing CSS into JavaScript via ES module syntax. Supports three import forms: side-effect imports to extract CSS into an external bundle, named imports to get CSS as a string, and import attributes to get a CSSStyleSheet. Features include minification, CSS Modules, runtime injection, preserveModules compatibility, and output file configuration. Differentiators include small size, import-order preservation, and no built-in Sass/Less processing (offers transform function instead). Requires Rollup ^2.x || ^3.x || ^4.x and Node >=16.
npm install rollup-plugin-import-cssVerified import paths — ran on the pinned version, not inferred.
Shows configuration with options (output, minify) and all three CSS import forms.
Upgrade Rollup to ^3.0.0 or ^4.0.0.
Configure the `transform` function with a library like clean-css or cssnano.
If you don't want CSS imports in the final bundle, add `preserveImports: false` to the plugin options.
Upgrade Rollup to version 3 or 4, or use side-effect import (import './file.css') instead.
Ensure the plugin is called with correct options: css({ output: 'styles.css' }).Check the relative path from the importing module; the plugin only processes valid CSS imports.