Rollup plugin that imports Sass/SCSS sources as constructable stylesheets for Lit (lit-html/lit-element) and FAST Element projects. Version 2.1.0, released 2024-12-10, supports Node >=18 and peer dependencies lit ^2||^3 and rollup ^2||^3||^4. Replaces rollup-plugin-styles + rollup-plugin-lit-css with a single step. Uses the official Sass compileString API, supports minification via cssnano or esbuild, custom PostCSS transforms, include/exclude patterns, and TypeScript declarations. Faster and simpler than alternative multi-plugin setups.
npm install rollup-plugin-scss-litVerified import paths — ran on the pinned version, not inferred.
Shows Rollup config with litScss plugin and a LitElement component importing a SCSS file as static styles.
Upgrade Node.js to >=18.
Update to v2.0.1+ for Lit 3 and Rollup 4 support.
Use plain minify: true with cssnano, or configure PostCSS plugins explicitly.
Create src/styles.d.ts declaring module '*.scss' with default export of type CSSResultGroup from 'lit'.
Check Sass compileString documentation for valid options. Avoid importer or syntax options meant for legacy API.
Add a copy plugin in rollup.config.js that copies src/**/*.scss to the outDir before other plugins run.
Create src/styles.d.ts: declare module '*.scss' { import { CSSResultGroup } from 'lit'; const styles: CSSResultGroup; export default styles; }Ensure rollup-plugin-scss-lit is installed (npm i -D rollup-plugin-scss-lit) and added to plugins: [litScss()] in rollup.config.js.
Use import { litScss } from 'rollup-plugin-scss-lit' (curly braces).