Registry / devops / rollup-plugin-css-only

rollup-plugin-css-only

JSON →
library4.5.5jsnpmunverified

A Rollup plugin (v4.5.5, stable) that bundles imported CSS files into a single asset rather than injecting them into the JavaScript bundle. Compared to rollup-plugin-postcss or rollup-plugin-styles, it is minimal—no CSS preprocessor support—and guarantees import order. Released under MIT, maintained by thgh, with compatibility for Rollup 2, 3, and 4 (since v4.4.0).

npm install rollup-plugin-css-only
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-CSS-
R
rollup-plugin-css-only
devopsjavascriptv4.5.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

css
import css from 'rollup-plugin-css-only'
const css = require('rollup-plugin-css-only')
The package provides a default export. ESM-only since v4.0.0.
RollupPluginCssOnly
import type { RollupPluginCssOnly } from 'rollup-plugin-css-only'
TypeScript users can import the plugin options type.
default export
import css from 'rollup-plugin-css-only'
import { css } from 'rollup-plugin-css-only'
Named export does not exist; must use default import.

Configures Rollup to bundle all imported CSS into a single 'bundle.css' asset, excluding minified files.

// rollup.config.js (ESM) import css from 'rollup-plugin-css-only'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'es', assetFileNames: 'assets/[name]-[hash][extname]' }, plugins: [ css({ include: ['**/*.css'], exclude: ['**/*.min.css'], output: 'bundle.css' // Custom output filename }) ] };
Debug
Known issues
breakingv4.0.0 changed CSS emission from writeFile to asset emission. Custom output behaviors must be updated.
fix
If you relied on writeFile, use the `output` option (a function or string) to define custom behavior.
affects: <4.0.0
breakingRollup v4 support requires rollup-plugin-css-only >=4.4.0. Older versions fail with Rollup v4.
fix
Upgrade to 4.4.0 or later, or stay on Rollup 3.
affects: <4.4.0
gotchaThe plugin does not support CSS preprocessors (Sass, Less, etc.) out of the box. For that use rollup-plugin-postcss.
fix
Use rollup-plugin-postcss or add a separate preprocessor plugin before this one.
affects: all
deprecatedThe `name` and `fileName` options are deprecated in favor of using the `output` option. They may be removed in a future major version.
fix
Use the `output` option to specify filename or custom logic.
affects: >=4.1.0
gotchaIf `output` is set to `false`, no CSS output is generated. This can be surprising if you expect a file to appear.
fix
Ensure you do not set output: false unless you intentionally want to suppress CSS output.
affects: >=4.0.0
Errors
Common errors & fixes
Error: You must specify output.assetFileNames or use plugin.options.output instead.
The plugin cannot determine a default output filename because assetFileNames is not configured.
fix
Set output.assetFileNames or pass an `output` option to the plugin (e.g., output: 'bundle.css').
TypeError: css is not a function
Importing the plugin incorrectly (e.g., as a named export instead of default).
fix
Use `import css from 'rollup-plugin-css-only'` (default import).
(!) Plugin rollup-plugin-css-only: This plugin is not compatible with Rollup 4. Please upgrade to v4.4.0 or later.
Using an older version of the plugin (<4.4.0) with Rollup v4.
fix
Upgrade to rollup-plugin-css-only@4.4.0 or later.
Error: ENOENT: no such file or directory, open 'bundle.css'
The plugin wrote CSS via writeFile in an older version, but the directory doesn't exist or output option disabled writing.
fix
For v4+, use the `output` option to control where and how CSS is emitted.
Upgrade
Version history
4.5.5latest on npm
Audit
Dependencies
@rollup/pluginutilsrequiredUsed for include/exclude pattern matching
rolluprequiredPeer dependency; plugin works with Rollup <5
Agent activity
7 hits · last 30 days
node
6
Resources
rollup-plugin-css-only — npm install rollup-plugin-css-only · libregistry