sass-loader

Compiles Sass and SCSS files to CSS inside a webpack build, wiring in Dart Sass or Sass Embedded automatically.

Tool
npm
v17.0.1
3,890 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
81 /100 Excellent
Development Activity 68
Maintenance 76
Community 80
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
79 /100 Good
Architecture 78
Code Quality 85
Innovation 68
Learning Curve 85

sass-loader is the official webpack loader for compiling Sass and SCSS source files to CSS as part of a webpack build. It sits ahead of css-loader and style-loader (or webpack’s built-in css/auto module type) in the module pipeline, resolving Sass @use, @import, and @forward requests through webpack’s own module resolution so stylesheets can pull in packages from node_modules the same way JavaScript modules do.

The loader doesn’t bundle a Sass compiler itself - it detects and calls into whichever implementation is installed, preferring sass-embedded and falling back to sass (Dart Sass), and exposes options for source maps, prepended data, and custom Sass options so teams can match their existing Sass tooling exactly.

What You Get

  • Webpack-native Sass compilation - runs Sass/SCSS files through Dart Sass or Sass Embedded and emits CSS webpack can pass on to css-loader or its built-in css/auto handling.
  • Automatic implementation resolution - detects whichever of sass-embedded or sass is installed in the project and prefers the faster embedded binary when both are present.
  • Webpack-aware @use/@import/@forward resolution - hands every Sass import to webpack’s resolver so resolve.alias, resolve.modules, and package exports conditions apply to stylesheets.
  • Source map support - normalizes Sass-generated source maps to webpack’s expected format so browser devtools point back to the original .scss source.

Common Use Cases

  • Compiling component stylesheets in a webpack app - a .scss file per component is compiled to CSS during the webpack build without a separate Sass CLI step.
  • Consuming Sass-authored design systems from node_modules - @use “bootstrap” or a design-system package resolves through webpack’s own module resolution instead of relative Sass includes.
  • Piping generated CSS into style-loader or mini-css-extract-plugin - sass-loader sits earliest in the loader chain, handing plain CSS off to whichever downstream loader injects or extracts styles.
  • Passing per-build Sass variables via additionalData - injecting environment- or theme-specific SCSS variables at the top of every compiled file without editing source.

Under The Hood

Architecture

sass-loader is a single-function webpack loader (src/index.js) wrapped by a large utilities module (src/utils.js, roughly 900 lines) that owns nearly every concern: resolving which Sass implementation to load (getSassImplementation), building the options object handed to the compiler (getSassOptions), constructing a webpack-aware Sass importer (getModernWebpackImporter) that bridges Sass’s import resolution to webpack’s own resolver via getWebpackResolver/startResolving, selecting between the modern and legacy compile APIs (getCompileFn), and post-processing output (source map normalization, BOM removal, error wrapping via errorFactory). The loader itself is a thin orchestrator: it fetches options via this.getOptions, awaits the implementation, options, and importer construction, calls the resolved compile function, and pushes results and dependencies back through webpack’s loader context (this.addDependency, callback). This function-per-concern shape inside one utils module, with no classes or DI container, is simple to trace, but it means anything that changes the webpack-Sass resolution bridge has to be understood as one unit rather than a swappable dependency.

Tech Stack

The package ships as a single ESM source module built to both ESM and CJS output (dist/esm, dist/cjs) via Babel, plus a separate tsc pass that emits only .d.ts type declarations into types/ from JSDoc-annotated source - there is no TypeScript source, just typed JS. It has zero runtime dependencies in package.json; Sass itself (sass and/or sass-embedded), webpack, and optionally @rspack/core are all peerDependencies, kept genuinely optional via peerDependenciesMeta. Dev tooling is a modern JS toolchain: an ESLint 9 flat config extending eslint-config-webpack, Prettier, cspell for spell-checking, Husky and lint-staged for pre-commit hooks, and Changesets for versioned releases. Tests exercise real Sass compilation against Dart Sass, Sass Embedded, bootstrap-sass, Bootstrap 4/5, Foundation, and Material Components Web installed as devDependencies, run through webpack itself using memfs for an in-memory filesystem.

Code Quality

Tests live under test/ as ten *.test.js suites (loader, resolver, options variants, source maps, CJS interop, validation) using Node’s built-in node:test runner with custom snapshot machinery rather than a third-party framework like Jest or Vitest - a deliberate choice that keeps sass-loader’s own test dependencies minimal. Coverage is collected via Node’s experimental test coverage flag and reported as lcov, and CI plus a dependency-review workflow gate merges. Options are validated at runtime via schema-utils against a JSON schema, so bad user options fail loudly at loader init rather than deep inside Sass compilation. Errors from the Sass compiler are wrapped through a dedicated error factory rather than surfaced raw, giving webpack a consistent error shape. Naming is consistent camelCase throughout, JSDoc typedefs stand in for TypeScript source types, and the flat ESLint config plus a dedicated spelling lint step keep style and docs quality enforced pre-commit.

What Makes It Unique

sass-loader’s most distinctive technical choice is bridging Sass’s own @use/@import/@forward resolution into webpack’s module resolver rather than relying on Sass’s file-system-only load paths: its modern webpack importer constructs a custom Sass importer whose hooks call back into webpack’s resolver factory, so aliases, extra module directories, and even package.json exports/sass/style conditions apply uniformly to stylesheets and JavaScript. It also transparently supports two independent Sass implementations - Dart Sass and the newer, faster Sass Embedded - behind one option surface, auto-preferring the embedded binary without users needing to change loader config when they upgrade. Neither idea is unique to sass-loader in the abstract, but implementing webpack-resolver-backed Sass imports as a first-class, zero-config default is a meaningfully more sophisticated integration than a typical wrapper loader that just shells out to a CLI.

Used by 48 apps in this directory

Go
62%
Apache 2.0

Harness Open Source

Code Editors · Developer Tools · Devops

38,684

A unified open source DevOps platform combining Git hosting, CI/CD pipelines, cloud development environments, and artifact registries in a single self-hosted system.

View details
90
Repo Health
79
Technical
64
Dependency
Built with
Go 62%
TypeScript 33%
Updated 1 weeks ago
TypeScript
71%
Other

highlight.io

Analytics · Developer Tools · Monitoring

9,384

Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.

View details
76
Repo Health
78
Technical
65
Dependency
Built with
TypeScript 71%
Go 16%
Updated 1 weeks ago
Rust
51%
Other

hoodik

File Storage · Security

1,539

Self-hosted, end-to-end encrypted cloud storage with browser-based encryption and S3-compatible storage support

View details
77
Repo Health
71
Technical
63
Dependency
Built with
Rust 51%
TypeScript 34%
Vue 14%
Updated 1 weeks ago
TypeScript
62%
EPL-2.0

Huly Platform

Collaboration · Project Management · Team Chat

27,978

Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.

View details
90
Repo Health
86
Technical
62
Dependency
Built with
TypeScript 62%
Svelte 34%
Updated 1 weeks ago
PHP
84%
Other

Invoice Ninja

Invoicing Finance · Project Management

10,311

Self-hostable invoicing, time-tracking, and multi-gateway payment platform for freelancers and small businesses, with built-in e-invoicing compliance for EU and global standards.

View details
97
Repo Health
83
Technical
62
Dependency
Built with
PHP 84%
Updated 1 weeks ago
TypeScript
98%
Other

Kibana

Analytics · Monitoring

21,338

Your open source window into the Elastic Stack — query, visualize, and act on data stored in Elasticsearch with real-time dashboards, AI-assisted search, and automated alerting.

View details
98
Repo Health
87
Technical
63
Dependency
Built with
TypeScript 98%
Updated 6 days ago
PHP
87%
AGPL 3.0

Kimai

Invoicing Finance · Project Management

5,095

Professional open-source time tracking with invoicing, multi-user support, SAML/LDAP auth, and a full REST API—self-host it or use the cloud.

View details
94
Repo Health
78
Technical
64
Dependency
Built with
PHP 87%
Updated 6 days ago
TypeScript
94%
AGPL 3.0

Laudspeaker

Automation · Marketing

2,629

Open-source customer engagement platform for building visual, event-triggered messaging journeys across email, SMS, push, in-app, and webhooks.

View details
45
Repo Health
66
Technical
62
Dependency
Built with
TypeScript 94%
Updated 3 months ago
JavaScript
42%
Other

LimeSurvey

Forms Surveys

3,778

The world's most flexible open-source survey platform with 900+ templates, conditional logic, 80+ languages, and full GDPR compliance for any scale.

View details
86
Repo Health
62
Technical
62
Dependency
Built with
JavaScript 42%
PHP 36%
CSS 12%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers