Registry /
web-framework / rollup-plugin-cssimport
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–223 runs
build_error
glibcnode 18–223 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
cssimport
✓ import cssimport from 'rollup-plugin-cssimport'
✗ const cssimport = require('rollup-plugin-cssimport')
Default export; plugin is ESM-only.
CSSStyleSheet
✓ import style from './styles.css';
const sheet = new CSSStyleSheet();
sheet.replaceSync(style);
✗ import * as style from './styles.css'; // returns module object, not string
Plugin returns the CSS as a string; you must create the CSSStyleSheet manually.
adoptedStyleSheets
✓ document.adoptedStyleSheets = [sheet];
✗ document.adoptedStyleSheets.push(sheet); // Array is frozen in some browsers
Assignment replaces entire array; use spread for add/remove.
Basic Rollup config using the plugin, importing CSS and applying as an adopted stylesheet.
// rollup.config.js
import cssimport from 'rollup-plugin-cssimport';
export default {
input: 'src/index.js',
output: {
file: 'dist/bundle.js',
format: 'iife'
},
plugins: [cssimport()]
};
// src/index.js
import style from './styles.css';
const sheet = new CSSStyleSheet();
sheet.replaceSync(style);
document.adoptedStyleSheets = [sheet];
Errors
Common errors & fixes
Error: "Unexpected token" when importing .css file without plugin
Missing plugin configuration in rollup.config.js.
fixAdd cssimport() to plugins array.
TypeError: Failed to construct 'CSSStyleSheet': 'replaceSync' is not a function
Browser does not support CSSStyleSheet.replaceSync (e.g., older Chrome).
fixUse sheet.replace(style) (async) or update browser.
TypeError: Cannot assign to read only property 'adoptedStyleSheets' of object '[object Document]'
Attempting to push to adoptedStyleSheets array.
fixAssign a new array, e.g., document.adoptedStyleSheets = [...document.adoptedStyleSheets, newSheet];
Audit
Dependencies
No dependency data recorded yet.