Vigil is a spark (plugin) for Catalyst Framework that provides development utilities including hot reloading. It automatically detects changes to templates, stylesheets, and JavaScript files, triggering browser refreshes to make your development workflow smoother.
- Comprehensive Hot Reload: Watches for changes in:
- Templates (
.tera
,.html
) - Stylesheets (
.css
,.scss
) - JavaScript/TypeScript (
.js
,.ts
)
- Templates (
- Multiple Directory Monitoring: Watches several key directories:
templates/
- For template filespublic/css/
- For CSS filespublic/js/
- For JavaScript filessrc/assets/
- For source assets (SCSS, TS, etc.)
- Intelligent Debouncing: Uses cooldown periods to prevent reload storms when multiple files are updated simultaneously
- Zero Configuration: Works out of the box with sensible defaults
- Development Mode Only: Only activates when Catalyst is in development mode
- Cascading Configuration: Settings can be adjusted through multiple methods with clear priority
- Self-contained: All necessary code is packaged within the spark - no external dependencies needed
- In development mode (
environment = "dev"
in Catalyst.toml), Vigil injects a JavaScript file into your HTML pages via HTTP headers - This script connects to a WebSocket endpoint provided by Vigil
- When files change, Vigil sends a message through the WebSocket with the changed file path and type
- The browser automatically refreshes to show the updated content
- Special error handling prevents console noise from missing scripts
Vigil supports a cascading configuration system with the following priority:
- Catalyst.toml (highest priority) - Configure in the
[spark.vigil]
section - Environment variables - Use variables like
VIGIL_REFRESH_INTERVAL
- manifest.toml - Default values in the
[config.defaults]
section - Hardcoded defaults (lowest priority)
Example configuration in Catalyst.toml:
[spark.vigil]
# Make checks more frequent for more responsive feedback
refresh_interval = 200
# Prevent multiple reloads from happening too close together
cooldown_period = 250
Available configuration options:
Option | Description | Default |
---|---|---|
template_hot_reload |
Enable/disable hot reload functionality | true |
refresh_interval |
Milliseconds between checking for file changes | 400 |
cooldown_period |
Milliseconds to wait after reload before checking again | 100 |
Vigil requires no user interaction - it's completely automatic:
- Make changes to your templates, stylesheets, or JavaScript files
- Save the file
- Your browser will automatically refresh to show the changes
Vigil is included as a core spark in Catalyst. As long as you have your environment set to "dev" in Catalyst.toml, it will activate automatically.
[settings]
environment = "dev"