{"id":21977,"library":"rollup-plugin-css-only","title":"rollup-plugin-css-only","description":"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).","status":"active","version":"4.5.5","language":"javascript","source_language":"en","source_url":"https://github.com/thgh/rollup-plugin-css-only","tags":["javascript","rollup-plugin","css"],"install":[{"cmd":"npm install rollup-plugin-css-only","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-css-only","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-css-only","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for include/exclude pattern matching","package":"@rollup/pluginutils","optional":false},{"reason":"Peer dependency; plugin works with Rollup <5","package":"rollup","optional":false}],"imports":[{"note":"The package provides a default export. ESM-only since v4.0.0.","wrong":"const css = require('rollup-plugin-css-only')","symbol":"css","correct":"import css from 'rollup-plugin-css-only'"},{"note":"TypeScript users can import the plugin options type.","wrong":"","symbol":"RollupPluginCssOnly","correct":"import type { RollupPluginCssOnly } from 'rollup-plugin-css-only'"},{"note":"Named export does not exist; must use default import.","wrong":"import { css } from 'rollup-plugin-css-only'","symbol":"default export","correct":"import css from 'rollup-plugin-css-only'"}],"quickstart":{"code":"// rollup.config.js (ESM)\nimport css from 'rollup-plugin-css-only';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'es',\n    assetFileNames: 'assets/[name]-[hash][extname]'\n  },\n  plugins: [\n    css({\n      include: ['**/*.css'],\n      exclude: ['**/*.min.css'],\n      output: 'bundle.css' // Custom output filename\n    })\n  ]\n};","lang":"javascript","description":"Configures Rollup to bundle all imported CSS into a single 'bundle.css' asset, excluding minified files."},"warnings":[{"fix":"If you relied on writeFile, use the `output` option (a function or string) to define custom behavior.","message":"v4.0.0 changed CSS emission from writeFile to asset emission. Custom output behaviors must be updated.","severity":"breaking","affected_versions":"<4.0.0"},{"fix":"Upgrade to 4.4.0 or later, or stay on Rollup 3.","message":"Rollup v4 support requires rollup-plugin-css-only >=4.4.0. Older versions fail with Rollup v4.","severity":"breaking","affected_versions":"<4.4.0"},{"fix":"Use rollup-plugin-postcss or add a separate preprocessor plugin before this one.","message":"The plugin does not support CSS preprocessors (Sass, Less, etc.) out of the box. For that use rollup-plugin-postcss.","severity":"gotcha","affected_versions":"all"},{"fix":"Use the `output` option to specify filename or custom logic.","message":"The `name` and `fileName` options are deprecated in favor of using the `output` option. They may be removed in a future major version.","severity":"deprecated","affected_versions":">=4.1.0"},{"fix":"Ensure you do not set output: false unless you intentionally want to suppress CSS output.","message":"If `output` is set to `false`, no CSS output is generated. This can be surprising if you expect a file to appear.","severity":"gotcha","affected_versions":">=4.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Set output.assetFileNames or pass an `output` option to the plugin (e.g., output: 'bundle.css').","cause":"The plugin cannot determine a default output filename because assetFileNames is not configured.","error":"Error: You must specify output.assetFileNames or use plugin.options.output instead."},{"fix":"Use `import css from 'rollup-plugin-css-only'` (default import).","cause":"Importing the plugin incorrectly (e.g., as a named export instead of default).","error":"TypeError: css is not a function"},{"fix":"Upgrade to rollup-plugin-css-only@4.4.0 or later.","cause":"Using an older version of the plugin (<4.4.0) with Rollup v4.","error":"(!) Plugin rollup-plugin-css-only: This plugin is not compatible with Rollup 4. Please upgrade to v4.4.0 or later."},{"fix":"For v4+, use the `output` option to control where and how CSS is emitted.","cause":"The plugin wrote CSS via writeFile in an older version, but the directory doesn't exist or output option disabled writing.","error":"Error: ENOENT: no such file or directory, open 'bundle.css'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}