A Rollup plugin that generates JavaScript files exporting CSS file contents as strings, paired with TypeScript declaration files. Version 1.0.3, stable, no recent updates. Designed for library authors needing to export CSS text for SSR-compatible CSS-in-JS (e.g., styled-components, Emotion). Unlike typical CSS extraction plugins, it creates companion .css-text.js files alongside original CSS files, preserving both. Requires Rollup >=2.61.1, and a separate CSS plugin (e.g., rollup-plugin-postcss) for actual CSS handling.
npm install rollup-plugin-css-textVerified import paths — ran on the pinned version, not inferred.
Shows typical usage with rollup-plugin-postcss, outputting CJS with named exports, disabling TS declarations.
Place a CSS plugin (e.g., rollup-plugin-postcss with extract: true) before css-text in the plugins array.
Use output.dir instead of output.file in Rollup config.
Upgrade to >=1.0.3 to use includeComments.
Evaluate if active maintenance is needed; consider alternatives if new features required.
Add output.dir to rollup config (e.g., output: { dir: 'dist', ... }).Use import cssText from 'rollup-plugin-css-text' (ESM) or use dynamic import if in CommonJS.