Registry / web-framework / rollup-plugin-scss

rollup-plugin-scss

JSON →
library4.0.1jsnpmunverified

A Rollup plugin for compiling .scss, .sass, and .css files into a single CSS file, with support for source maps, custom processors (e.g., PostCSS), and prefix injection. Version 4.0.1 is stable and actively maintained. It automatically uses the 'sass' package over 'node-sass', is written in TypeScript, and integrates seamlessly with Rollup's asset pipeline. Compared to alternatives like rollup-plugin-postcss, it focuses solely on Sass/SCSS compilation without additional CSS processing by default, offering a leaner setup for pure SCSS projects.

npm install rollup-plugin-scss
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-SCSS
R
rollup-plugin-scss
web-frameworkjavascriptv4.0.1
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.

default
import scss from 'rollup-plugin-scss'
const scss = require('rollup-plugin-scss')
ESM-only since v3. CommonJS require will fail.
scss
import scss from 'rollup-plugin-scss'
import { scss } from 'rollup-plugin-scss'
The plugin is exported as default, not a named export. Named import will yield undefined.
SassPluginOptions (TypeScript)
import type { SassPluginOptions } from 'rollup-plugin-scss'
TypeScript users can import the options type for type-safe configuration. Available in v3+.

Example Rollup config using rollup-plugin-scss with options: custom output filename, source maps, include/exclude patterns, error handling, and output callback.

// rollup.config.js import scss from 'rollup-plugin-scss'; export default { input: 'src/index.js', output: { file: 'dist/bundle.js', format: 'esm', assetFileNames: '[name][extname]' }, plugins: [ scss({ fileName: 'bundle.css', sourceMap: true, output: (styles, styleNodes) => { console.log(`Generated ${styles.length} bytes of CSS`); }, include: ['**/*.scss'], exclude: ['**/vendor/**'], failOnError: true, verbose: false }) ] };
Debug
Known issues
breakingv3 removed node-sass from optionalDependencies; you must install sass or node-sass explicitly.
fix
Add 'sass' (or 'node-sass') to your devDependencies: npm install --save-dev sass
affects: >=3.0.0
breakingv3 switched to ESM-only; CommonJS require no longer works.
fix
Use dynamic import if needed: const scss = (await import('rollup-plugin-scss')).default;
affects: >=3.0.0
breakingThe 'output' callback signature changed in v3: second parameter is an array of style objects instead of a single string.
fix
Update callback: function(styles, styleNodes) where styleNodes is Array<{filename: string, content: string}>
affects: >=3.0.0
deprecatedThe 'name' option is deprecated in favor of 'fileName' since v3.
fix
Use 'fileName' instead of 'name' to set the output CSS filename.
affects: >=3.0.0
gotchaIf both 'sass' and 'node-sass' are installed, 'sass' is preferred; this may cause unexpected behavior if your project depends on node-sass specifics.
fix
Explicitly set the 'sass' option to the compiler you want: sass: require('node-sass')
affects: >=3.0.0
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-scss'
Package not installed or ESM-only package loaded with require in Node < 12.
fix
Install: npm install --save-dev rollup-plugin-scss. For CJS, use dynamic import: const scss = (await import('rollup-plugin-scss')).default;
TypeError: scss is not a function
Named import { scss } used instead of default import.
fix
Use default import: import scss from 'rollup-plugin-scss'
Error: Options.output must be of type function or false, got object
Passing an object to the 'output' option; it expects a function or boolean false.
fix
Set 'output' to a callback function or false: output: (styles, styleNodes) => { ... }
Error: Cannot find module 'sass'
Missing Sass compiler dependency.
fix
Install sass or node-sass: npm install --save-dev sass
Upgrade
Version history
4.0.1latest on npm
Audit
Dependencies
sassoptionalRequired peer dependency: the compiler used to transpile SCSS/SASS. Either this or node-sass must be installed.
node-sassoptionalOptional alternative compiler if 'sass' is not installed. Automatically detected if present.
Agent activity
15 hits · last 30 days
node
12
OpenAI (training)
1
Resources
rollup-plugin-scss — npm install rollup-plugin-scss · libregistry