Automatically re-run tasks when files change. No more switching to the terminal
and running jake build after every edit.
@watch directive for tasks is_watching() for dev-only behavior # File target - watched automatically
file dist/bundle.js: src/**/*.ts
esbuild src/index.ts --bundle --outfile=dist/bundle.js
# Task with explicit watch patterns
task dev:
@watch src/**/*.ts tests/**/*.ts
npm run dev
# Conditional behavior during watch
task build:
@if is_watching()
echo "Quick dev build..."
esbuild src/index.ts --bundle --outfile=dist/app.js
@else
echo "Full production build..."
npm run lint
npm run typecheck
esbuild src/index.ts --bundle --minify --outfile=dist/app.js
@end Jake watches your source files and rebuilds when they change.
Jake collects patterns from file target dependencies and @watch directives.
Uses FSEvents (macOS) or inotify (Linux) for efficient file watching.
When a watched file changes, Jake re-runs the task. With -v, it shows which file triggered it.
$ jake -w build
[watch] Watching 47 file(s) for changes...
[watch] Patterns: src/**/*.ts
[watch] Press Ctrl+C to stop
→ build
Quick dev build...
esbuild src/index.ts --bundle --outfile=dist/app.js
✓ build (0.42s)
# Edit src/index.ts...
[watch] Change detected: src/index.ts
→ build
Quick dev build...
✓ build (0.18s)
# Jake keeps watching...
Use is_watching() to skip expensive operations during development.
Watch mode for every development workflow.
Auto-refresh on any source file change.
task dev:
@watch src/**/*.{ts,tsx,css}
npm run dev jake -w dev Tests re-run automatically as you code.
task test:
@watch src/**/*.ts tests/**/*.ts
npm test jake -w test Live preview of documentation changes.
task docs:
@watch docs/**/*.md
mkdocs serve jake -w docs Chained file targets rebuild on change.
file dist/compiled.js: src/**/*.ts
tsc
file dist/bundle.js: dist/compiled.js
esbuild dist/compiled.js --bundle -o dist/bundle.js jake -w dist/bundle.js Common watch mode commands.
jake -w build Watch and rebuild on changes jake -w "src/**/*.ts" build Watch specific pattern jake -w -v build Verbose - show which files changed jake -w -j4 build Parallel rebuilds on change Neither Make nor Just has built-in watch mode. You need external tools.
# Need external tools
fswatch -o src/ | xargs -n1 make build
# Or install watchexec
watchexec -e ts just build
# Or nodemon
nodemon --watch src -e ts --exec "just build" $ jake -w build
# That's it. Built-in.
# No extra tools needed.