{"id":22210,"library":"rollup-plugin-sass-modules","title":"rollup-plugin-sass-modules","description":"A Rollup plugin that imports and compiles SASS/SCSS files as modules, supporting sourcemaps and extraction of CSS files. Version 1.4.0 is the latest stable release. It integrates with dart-sass and allows import from `node_modules`. Key differentiator: exports the dependency tree to Rollup and supports post-processing via a `processor` function. Ideal for projects using Rollup as a bundler who want to use Sass with CSS modules or extracted CSS.","status":"active","version":"1.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/edoardocavazza/rollup-plugin-sass-modules","tags":["javascript"],"install":[{"cmd":"npm install rollup-plugin-sass-modules","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-sass-modules","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-sass-modules","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; plugin is designed to work with Rollup","package":"rollup","optional":true}],"imports":[{"note":"Package supports ESM; default import.","wrong":"const sassModules = require('rollup-plugin-sass-modules')","symbol":"sassModules","correct":"import sassModules from 'rollup-plugin-sass-modules'"},{"note":"Use named export if preferred, but default export is the primary way.","wrong":"import sassModules from 'rollup-plugin-sass-modules'","symbol":"sassModules","correct":"import { sassModules } from 'rollup-plugin-sass-modules'"},{"note":"CommonJS users must access `.default` due to ESM-first design.","wrong":"const sassModules = require('rollup-plugin-sass-modules')","symbol":"sassModules","correct":"const sassModules = require('rollup-plugin-sass-modules').default"}],"quickstart":{"code":"import sassModules from 'rollup-plugin-sass-modules';\nimport { babel } from '@rollup/plugin-babel';\nimport resolve from '@rollup/plugin-node-resolve';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    file: 'dist/bundle.js',\n    format: 'iife',\n  },\n  plugins: [\n    resolve(),\n    sassModules({\n      include: ['**/*.scss', '**/*.sass'],\n      exclude: ['node_modules'],\n      options: {\n        outputStyle: 'compressed',\n        sourceMap: true,\n      },\n    }),\n    babel({ babelHelpers: 'bundled' }),\n  ],\n};","lang":"javascript","description":"Configures Rollup to compile Sass files as modules, enabling imports from JavaScript and generating sourcemaps."},"warnings":[{"fix":"Upgrade to Rollup >= 1.0.0.","message":"Version 1.x requires peer dependency of Rollup >=1.0.0; older Rollup versions (0.x) break.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure processor returns a Promise resolving to { code, map }.","message":"The `processor` option accepts a function returning a Promise; using synchronous processor is deprecated.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Set `options.outFile` to extract CSS to a file, or use `emitCss: true` option (if supported).","message":"By default, the plugin does not extract CSS unless `options.outFile` is provided. Without it, CSS is emitted as a module.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use full path with extension, e.g., `import './styles.scss'`.","message":"Importing .sass or .scss files requires the file extension in the import statement.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Run `npm install sass --save-dev`.","message":"The plugin uses dart-sass (the `sass` package) internally; ensure it is installed as a dev dependency.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run `npm install rollup-plugin-sass-modules --save-dev`.","cause":"Package not installed or missing from package.json devDependencies.","error":"Error: Cannot find module 'rollup-plugin-sass-modules'"},{"fix":"Use `const sassModules = require('rollup-plugin-sass-modules').default` for CommonJS, or use ESM import.","cause":"CommonJS require() without accessing .default; or using named import when default is expected.","error":"TypeError: sassModules is not a function"},{"fix":"Install the `sass` package as devDependency.","cause":"dart-sass peer dependency not installed.","error":"Error: The 'sass' package is required. Please install it: npm install sass --save-dev"},{"fix":"Add `options: { outFile: 'dist/styles.css' }` to plugin config.","cause":"CSS extraction attempted without providing outFile in options.","error":"Error: You must specify an 'outFile' option to extract CSS."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}