The Sass --watch flag (short: -w) keeps the compiler running and rebuilds CSS whenever you save. This page covers single-file watch, folder watch with colon pairs, --poll, npm scripts, and five practical examples.
01
--watch
Stay running
02
One file
in → out
03
Folders
src:css
04
--poll
Network drives
05
Stop
Ctrl+C
06
Practice
5 examples
Concept
What Is --watch?
Without flags, sass input.scss output.css compiles once and exits. With --watch, Sass compiles, then keeps listening for file changes and recompiles automatically—perfect while you learn or build a site.
Recompile on every save of watched Sass (and many of its dependencies).
Watch one file pair or an entire input folder.
Leave the terminal open; stop with Ctrl+C.
Pair with other flags like --style=compressed when you need them.
💡
Beginner tip
Install Sass first (Installation), then use Dart Sass CLI basics. This page zooms in on watching only.
Foundation
📝 Basic Syntax
From the Sass Basics guide: add the watch flag to a normal compile command.
terminal
# Watch one file → one CSS file
sass --watch input.scss output.css
# Same thing, short flag
sass -w input.scss output.css
Every time you save input.scss, Sass updates output.css and prints a short compile message.
Folders
📁 Watch Directories
To watch and output whole folders, use folder paths separated by a colon (: (many-to-many mode):
terminal
sass --watch app/sass:public/stylesheets
Sass watches everything in app/sass and writes CSS into public/stylesheets. Partials named with a leading underscore (_partial.scss) are not emitted as their own CSS files.
⚠️
What gets watched?
Official Dart Sass behavior: directories you pass on the command line (and load paths) are watched—not every folder that only appears through @use deep elsewhere. Prefer watching your real source root.
Options
⚙️ --poll, --update & Friends
--poll — only with --watch; manually check for changes when OS notifications fail (VMs, some network drives).
--update — compile only out-of-date stylesheets once, then exit (not a long-running watcher).
--style=compressed — still works while watching if you want smaller CSS during local checks.
--stop-on-error — stop compiling more files after the first error (useful in strict setups).
Workflow
📦 npm Script Pattern
Most projects wrap watch in package.json so teammates run one command:
Commands match the Sass guide and Dart Sass CLI. Open View Typical Log for sample terminal output.
📚 Getting Started
Watch a single stylesheet or an entire Sass folder.
Example 1 — Watch One File
From the official guide: watch input.scss and write output.css.
terminal
sass --watch input.scss output.css
📤 Typical terminal log:
Compiled input.scss to output.css.
# After you save input.scss again...
Compiled input.scss to output.css.
How It Works
Sass compiles once, then waits. Each save triggers another compile into the same output path. Leave the process running in its own terminal tab.
Example 2 — Watch a Folder Pair
Watch app/sass and emit CSS under public/stylesheets.
terminal
sass --watch app/sass:public/stylesheets
📤 Typical terminal log:
Compiled app/sass/main.scss to public/stylesheets/main.css.
Compiled app/sass/home.scss to public/stylesheets/home.css.
# After you edit app/sass/home.scss...
Compiled app/sass/home.scss to public/stylesheets/home.css.
How It Works
Colon syntax means many-to-many: each non-partial Sass file maps to a CSS file in the output directory. Edits recompile the affected stylesheet.
📈 Poll, npm & Style Flags
Make watching reliable in real projects.
Example 3 — Watch with --poll
Use when native file watchers miss updates on network or virtual disks.
terminal
sass --watch --poll themes:public/css
📤 Typical terminal log:
Compiled themes/light.scss to public/css/light.css.
# Sass is polling for changes...
# After you save themes/dark.scss...
Compiled themes/dark.scss to public/css/dark.css.
How It Works
--poll is only valid with --watch. Sass checks timestamps on a timer instead of relying solely on OS notifications.
Example 4 — npm sass:watch Script
Share one command with your team via package.json.
terminal
# package.json → "sass:watch": "sass --watch scss:css"
npm run sass:watch
Watch mode does not lock you into expanded CSS. Flags like --style still apply on every rebuild. For production CI, prefer a one-shot compile without --watch.
Applications
🚀 Real-World Use Cases
Learning Sass — save SCSS, refresh the browser, see CSS update.
Local site builds — sass --watch scss:public/css beside your static server.
Multi-theme folders — watch themes:css for light/dark packs.
Team npm scripts — document npm run sass:watch in the README.
Flaky file systems — add --poll on VMs or network mounts.
🧠 How Watching Works
1
Start once
Compile all matching inputs to CSS immediately.
Compile
2
Listen
Watch passed paths (native events or --poll).
Watch
3
On change
Rebuild affected stylesheets and print a short log line.
Rebuild
4
✓
Repeat until Ctrl+C
Process stays alive until you stop it.
Watch Out
⚠️ Common Pitfalls
Wrong separator — folder mode needs input:output, not a space between two folders.
Watching the wrong root — only directories you pass (and load paths) are watched reliably.
Leaving watchers forever — stop with Ctrl+C; avoid dozens of forgotten terminals.
Using --watch in CI — CI should one-shot compile; watch never exits on its own.
Confusing --update with watch — --update compiles outdated files once, then exits.
Pro Tips
💡 Best Practices
✅ Do
Use --watch for local editing sessions
Watch your Sass source root with src:css
Add an npm script named sass:watch
Try --poll if saves do not trigger rebuilds
Keep one dedicated terminal tab for the watcher
❌ Don’t
Run --watch in production deploy scripts
Expect partials (_*.scss) to become CSS files
Mix up space pairs vs colon folder pairs
Ignore compile errors in the watch log
Forget Ctrl+C before closing the machine for the day
Summary
Key Takeaways
👀01
--watch / -w
auto-rebuild
Core
📄02
File pair
in.scss out.css
Basic
📁03
Folders
src:css
Scale
♻️04
--poll
when needed
Fix
🛑05
Ctrl+C
stop watcher
Stop
❓ Frequently Asked Questions
It compiles your Sass once, then keeps running and recompiles whenever watched source files (or their dependencies) change. Ideal while you edit styles locally.
Use a space-separated pair: sass --watch input.scss output.css. Every time you save input.scss, Sass updates output.css.
Use a colon between folders: sass --watch app/sass:public/stylesheets. Sass watches the input folder and writes CSS into the output folder.
Use -w. Example: sass -w scss:css. Same behavior as --watch.
If file-change notifications fail (common on some network or virtual drives), add --poll with --watch so Sass checks for changes on a timer instead of relying on the OS watcher.
Focus the terminal and press Ctrl+C (Cmd+C on some setups). That ends the watcher process.
Did you know?
The Sass Basics guide introduces watching early because it is the fastest feedback loop for beginners: install Sass, run sass --watch, edit SCSS, and see CSS appear without retyping the compile command every time.
sass --watch turns compile-on-demand into a live loop: save Sass, get fresh CSS. Watch a file or a folder pair, add --poll when needed, and stop with Ctrl+C when you are done.