The Dart Sass command-line interface compiles Sass from your terminal. This page covers one-to-one and many-to-many modes, key flags (--style, --watch, source maps, stdin), and five beginner examples. Install first via Sass Installation.
01
One-to-one
in out
02
Many-to-many
in:out
03
--style
expanded / compressed
04
--watch
Live rebuild
05
Maps & stdin
Dev extras
06
Practice
5 examples
Concept
What Is the Dart Sass CLI?
After you install Dart Sass, you get a sass executable. It reads .scss / .sass (and sometimes .css), parses the stylesheet, and writes CSS—either to a file or to the terminal.
Unknown extensions or stdin default to SCSS (override with --indented).
Partials named _file.scss are skipped when compiling whole directories.
Use sass --help and sass --version anytime.
💡
Beginner tip
Start with sass styles.scss styles.css. When that works, add --watch for day-to-day editing and --style=compressed for production builds.
Modes
📄 One-to-One Mode
terminal
sass <input.scss> [output.css]
Compiles a single input to a single output. Omit the output path to print CSS to the terminal. Pass - as the input to read from standard input (defaults to SCSS unless --indented is set).
Modes
📦 Many-to-Many Mode
Official docs (Dart Sass 1.4.0+): separate inputs from outputs with a colon. You can list several pairs or map a whole directory.
terminal
# One file pair
sass style.scss:style.css
# Several files
sass light.scss:light.css dark.scss:dark.css
# All Sass files in themes/ → public/css/ (skips _partials)
sass themes:public/css
Flags
⚙️ Important Options
Option
What it does
--style / -s
expanded (default) or compressed
--watch / -w
Recompile when sources change (like --update, then keep running)
--update
Compile only out-of-date stylesheets
--stdin
Read SCSS/Sass from stdin (not with many-to-many)
--indented
Force indented syntax (handy for stdin)
--load-path / -I
Extra folders for @use / imports (repeatable)
--no-source-map
Do not write .css.map files
--quiet / -q
Hide warnings (and silence @debug)
--interactive / -i
REPL for SassScript expressions
--error-css
On error, emit CSS that shows the message in the browser (on by default when writing files)
Also useful: --poll (with --watch on flaky network drives), --stop-on-error, --verbose, --quiet-deps, --fatal-deprecation, --no-charset, and source-map embedding flags. Run sass --help for the full list on your installed version.
💡
Version note
Some flags need newer Dart Sass (for example --pkg-importer=node since 1.71.0). This site’s examples target common flags available on Dart Sass 1.69+. Upgrade if a flag is missing from sass --help.
Debugging
🔍 Source Maps
By default, Dart Sass writes source maps next to CSS files so DevTools can show the original SCSS. Disable with --no-source-map. Control link style with --source-map-urls=relative|absolute, or embed with --embed-sources / --embed-source-map.
Cheat Sheet
⚡ Quick Reference
Goal
Command
Compile one file
sass styles.scss styles.css
Print CSS only
sass styles.scss
Colon pair
sass styles.scss:styles.css
Folder → folder
sass scss:css
Watch
sass --watch scss:css
Production CSS
sass --style=compressed --no-source-map scss:css
From stdin
echo "h1{color:red}" | sass --stdin
Interactive
sass --interactive
Hands-On
Examples Gallery
Verified with Dart Sass. Open each toggle for CSS or terminal output.
📚 Getting Started
Compile a single file, then a whole folder.
Example 1 — One-to-One Compile (Stdout)
Omit the output path to print CSS in the terminal.
sass style.scss
# or write a file:
sass style.scss style.css
sass style.scss:style.css
📤 Compiled CSS:
h1 {
font-size: 40px;
color: #036;
}
How It Works
Space-separated paths are one-to-one mode. Colon pairs are many-to-many mode for the same single file. Both produce the same CSS.
Example 2 — Compile a Directory (Skip Partials)
Map themes/ to css/. Files starting with _ are not emitted.
terminal
# themes/light.scss, themes/dark.scss, themes/_tokens.scss
sass themes:css
# Result: css/light.css and css/dark.css
# (_tokens.scss is a partial — no css/_tokens.css)
📤 Output files:
css/light.css
css/light.css.map
css/dark.css
css/dark.css.map
# no css/_tokens.css
How It Works
Directory mode keeps shared tokens in partials without creating empty CSS files for them.
📈 Style, Stdin & Watch
Production CSS, piping input, and the live-reload loop.
--stdin (or input -) cannot be combined with many-to-many colon mode. Great for quick experiments.
Example 5 — Watch a Folder
After the first compile, Sass stays open and rebuilds on change.
terminal
sass --watch themes:public/css
# Remote / network drives if OS notifications fail:
sass --watch --poll themes:public/css
# Only rebuild outdated files once:
sass --update themes:public/css
📤 Typical terminal log:
Compiled themes/light.scss to public/css/light.css.
# After you edit themes/dark.scss...
Compiled themes/dark.scss to public/css/dark.css.
How It Works
Official docs: Sass watches directories you pass on the command line (and load paths)—not every folder discovered only through @use. Stop with Ctrl+C.
Applications
🚀 Real-World Use Cases
Local learning — one-to-one compile + stdout for instant feedback.
Multi-theme sites — sass --watch themes:css.
CI production — --style=compressed --no-source-map.
npm scripts — wrap CLI commands in package.json.
Quick math checks — sass --interactive for SassScript.
🧠 How the CLI Compiles
1
Pick mode
One-to-one paths or many-to-many colon pairs / folders.
Invoke
2
Load & parse
Resolve syntax, load paths, and dependencies.
Read
3
Apply flags
Style, source maps, quiet, update/watch behavior.
Options
4
✓
Emit CSS
Write files (and maps) or print to the terminal.
Watch Out
⚠️ Common Pitfalls
Mixing modes — do not combine --stdin with many-to-many pairs.
Expecting partial CSS — _partial.scss is skipped in directory compiles.
Watch not seeing deep folders — only passed dirs / parents / load paths are watched.
Surprise source maps — default on; use --no-source-map for clean deploys.
Editing generated CSS — the next sass run overwrites it.
Pro Tips
💡 Best Practices
✅ Do
Put CLI commands in npm scripts for the team
Use --watch locally and one-shot compile in CI
Prefer directory many-to-many for multi-file themes
Keep shared code in _partials
Run sass --version in CI to pin/debug toolchains
❌ Don’t
Commit compressed CSS as your only source
Ignore deprecation warnings forever—use --verbose when cleaning up
Assume every flag exists on older Dart Sass
Use absolute source-map URLs if CSS will be served elsewhere
Forget Ctrl+C to stop a watcher before closing the terminal
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about the Dart Sass CLI
Two modes, clear flags, watch for dev, compress for prod.
5
Core concepts
📄01
One-to-one
file → file
Mode
📦02
Many-to-many
in:out / dirs
Mode
⚙️03
--style
expanded / min
Output
👀04
--watch
live rebuild
Dev
🔍05
Source maps
on by default
Debug
❓ Frequently Asked Questions
The sass executable that compiles .scss, .sass, and sometimes .css files to CSS from the terminal. Install it via npm, Homebrew, Chocolatey, or a standalone binary.
sass <input.scss> [output.css] compiles one input file to one output file (or prints CSS to the terminal if you omit the output path).
sass input:output or sass srcDir:outDir compiles one or more pairs. Directory mode writes CSS for each Sass file and skips partials that start with _.
Pass --watch (or -w), usually with colon pairs: sass --watch themes:public/css. Sass recompiles when those files or their dependencies change.
Controls CSS formatting. expanded (default) is readable. compressed removes extra whitespace for production.
Yes when writing CSS files. Pass --no-source-map to skip them. Other flags control relative/absolute URLs and embedding.
Did you know?
Official docs include an interactive mode (sass --interactive) where you can type SassScript like 1px + 1in and see 97px—handy for learning units without creating a stylesheet.
The Dart Sass CLI is your day-to-day compile tool: one-to-one for single files, many-to-many for folders, --watch while editing, and --style=compressed when shipping. Master those, then dive into language features.