{"id":22109,"library":"rollup-plugin-lib-style","title":"Rollup Plugin Lib Style","description":"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.","status":"active","version":"2.5.0","language":"javascript","source_language":"en","source_url":"https://github.com/danielamenou/rollup-plugin-lib-style","tags":["javascript","library","rollup","plugin","style","sass","scss","css","typescript"],"install":[{"cmd":"npm install rollup-plugin-lib-style","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-lib-style","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-lib-style","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only package; require() will not work.","wrong":"const libStylePlugin = require('rollup-plugin-lib-style')","symbol":"libStylePlugin","correct":"import { libStylePlugin } from 'rollup-plugin-lib-style'"},{"note":"Default export is also available but named export is preferred for tree-shaking.","wrong":"","symbol":"default","correct":"import libStylePlugin from 'rollup-plugin-lib-style'"},{"note":"Type exported for TypeScript users.","wrong":"","symbol":"LibStylePluginOptions","correct":"import type { LibStylePluginOptions } from 'rollup-plugin-lib-style'"}],"quickstart":{"code":"// rollup.config.js\nimport { libStylePlugin } from 'rollup-plugin-lib-style';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'es',\n    preserveModules: true\n  },\n  plugins: [\n    libStylePlugin({\n      // Optional: custom postcss config\n      postcss: {\n        modules: true\n      }\n    })\n  ]\n};\n\n// src/components/Button.js\nimport styles from './Button.css';\n\nconst Button = () => {\n  const button = document.createElement('button');\n  button.className = styles.button;\n  button.textContent = 'Click me';\n  return button;\n};\n\nexport default Button;","lang":"typescript","description":"Shows minimal Rollup config with preserveModules, CSS module usage, and plugin setup."},"warnings":[{"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).","message":"The plugin generates .css.js files alongside .css files. These extra files may be included in the bundle if not handled properly.","severity":"gotcha","affected_versions":">=0"},{"fix":"Update Node to >=16.","message":"The plugin requires Node >=16. Older Node versions cause runtime errors.","severity":"gotcha","affected_versions":">=0"},{"fix":"Use import syntax in your Rollup config or run Node with --experimental-require-module.","message":"The plugin is ESM-only. CommonJS require() will fail with ERR_REQUIRE_ESM.","severity":"gotcha","affected_versions":">=0"},{"fix":"Update to 2.x and use named export { libStylePlugin } or default export.","message":"Version <2.x used a different export pattern (default export only).","severity":"deprecated","affected_versions":"<2.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Replace require('rollup-plugin-lib-style') with import { libStylePlugin } from 'rollup-plugin-lib-style'.","cause":"Using CommonJS require() to import the plugin.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module not supported."},{"fix":"Verify you are using the named export: import { libStylePlugin } from 'rollup-plugin-lib-style'.","cause":"Incorrect import; plugin is not default exported in older versions?","error":"TypeError: libStylePlugin is not a function"},{"fix":"Upgrade Node to 16 or higher.","cause":"Running on unsupported Node version.","error":"Node.js v14.17.0 is not supported: rollup-plugin-lib-style requires Node >=16"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}