Sass --watch

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
CLI flag

What You’ll Learn

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

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.

📝 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.

📁 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.

⚙️ --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).

📦 npm Script Pattern

Most projects wrap watch in package.json so teammates run one command:

terminal
{
  "scripts": {
    "sass": "sass scss:css",
    "sass:watch": "sass --watch scss:css"
  }
}

Then run npm run sass:watch during development.

⚡ Quick Reference

GoalCommand
Watch one filesass --watch in.scss out.css
Short flagsass -w in.scss out.css
Watch a foldersass --watch scss:css
Unreliable FS eventssass --watch --poll scss:css
One-shot outdated onlysass --update scss:css
Stop the watcherCtrl+C in the terminal

Examples Gallery

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

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

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

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

How It Works

npm runs the script string as a shell command. Make sure the sass package is installed locally or the binary is on your PATH.

Example 5 — Watch + Compressed Style

Combine watch with formatting flags while still auto-rebuilding.

terminal
sass --watch --style=compressed scss:dist/css
styles.scss
.button {
  padding: 0.5rem 1rem;
  background: #036;
  color: #fff;

  &:hover { background: #024; }
}

How It Works

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.

🚀 Real-World Use Cases

  • Learning Sass — save SCSS, refresh the browser, see CSS update.
  • Local site buildssass --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.

⚠️ 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.

💡 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

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.

Conclusion

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.

Continue with Ruby Sass CLI or the full Dart Sass CLI reference.

Next: Ruby Sass CLI

Legacy CLI notes—prefer Dart Sass for new work.

Ruby Sass CLI →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful