Registry / serialization / rollup-plugin-lib-style

rollup-plugin-lib-style

JSON →
library2.5.0jsnpmunverified

A Rollup plugin for building component libraries with tree-shakeable, per-component CSS. Version 2.5.0 (stable). It converts CSS and preprocessor files (SASS/SCSS, Less, Stylus) into CSS modules, generating a separate CSS file per component with scoped class names. Unlike single CSS file bundling (bloat) or CSS-in-JS (runtime overhead), this plugin outputs plain CSS with zero runtime cost and automatic scoping. Works with preserveModules and code splitting. ESM-only, requires Node >=16. Ships TypeScript types.

npm install rollup-plugin-lib-style
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-LIB-
R
rollup-plugin-lib-style
serializationjavascriptv2.5.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

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

libStylePlugin
✓ import { libStylePlugin } from 'rollup-plugin-lib-style'
✗ const libStylePlugin = require('rollup-plugin-lib-style')
ESM-only package; require() will not work.
default
✓ import libStylePlugin from 'rollup-plugin-lib-style'
Default export is also available but named export is preferred for tree-shaking.
LibStylePluginOptions
✓ import type { LibStylePluginOptions } from 'rollup-plugin-lib-style'
Type exported for TypeScript users.

Shows minimal Rollup config with preserveModules, CSS module usage, and plugin setup.

// rollup.config.js import { libStylePlugin } from 'rollup-plugin-lib-style'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'es', preserveModules: true }, plugins: [ libStylePlugin({ // Optional: custom postcss config postcss: { modules: true } }) ] }; // src/components/Button.js import styles from './Button.css'; const Button = () => { const button = document.createElement('button'); button.className = styles.button; button.textContent = 'Click me'; return button; }; export default Button;
Debug
Known issues
gotchaThe plugin generates .css.js files alongside .css files. These extra files may be included in the bundle if not handled properly.
fix
Ensure Rollup's output does not include the temporary .css.js files in final distribution (they are typically removed by build cleanup or ignored by .npmignore).
affects: >=0
gotchaThe plugin requires Node >=16. Older Node versions cause runtime errors.
fix
Update Node to >=16.
affects: >=0
gotchaThe plugin is ESM-only. CommonJS require() will fail with ERR_REQUIRE_ESM.
fix
Use import syntax in your Rollup config or run Node with --experimental-require-module.
affects: >=0
deprecatedVersion <2.x used a different export pattern (default export only).
fix
Update to 2.x and use named export { libStylePlugin } or default export.
affects: <2.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported.
Using CommonJS require() to import the plugin.
fix
Replace require('rollup-plugin-lib-style') with import { libStylePlugin } from 'rollup-plugin-lib-style'.
TypeError: libStylePlugin is not a function
Incorrect import; plugin is not default exported in older versions?
fix
Verify you are using the named export: import { libStylePlugin } from 'rollup-plugin-lib-style'.
Node.js v14.17.0 is not supported: rollup-plugin-lib-style requires Node >=16
Running on unsupported Node version.
fix
Upgrade Node to 16 or higher.
Upgrade
Version history
2.5.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
rollup-plugin-lib-style — npm install rollup-plugin-lib-style · libregistry