Sass/SCSS
Dodeca compiles Sass/SCSS stylesheets automatically.
Directory structure
Place your Sass files in a sass/ directory at your project root:
my-site/
├── .config/
│ └── dodeca.yaml
├── content/
├── sass/
│ ├── main.scss # Entry point (required)
│ ├── _variables.scss # Partial (not compiled directly)
│ └── _components.scss # Another partial
├── static/
└── templates/
Entry point
The file sass/main.scss is the entry point. This is the only file that gets compiled directly - all other styles should be imported from here.
If main.scss doesn't exist, SCSS compilation is skipped (no error).
Partials
Files starting with _ are partials. They're not compiled on their own but can be imported:
// _variables.scss
$primary-color : # 3498db ;
$font-stack : system-ui , sans-serif ;
// _components.scss
. button {
background : $primary-color ;
padding : 0.5 rem 1 rem ;
}
Import them in main.scss using @use:
// main.scss
@use "variables" ;
@use "components" ;
body {
font-family : variables.$font-stack ;
color : variables.$primary-color ;
}
Note: Use @use (modern Sass) rather than @import (deprecated).
Using in templates
Reference the compiled CSS in your templates:
< link rel ="stylesheet " href ="/main.css ">
Dodeca automatically:
- Compiles
sass/main.scssto CSS - Rewrites URLs inside the CSS (for images, fonts, etc.)
- Adds a content hash for cache busting (e.g.,
/main.a1b2c3d4.css) - Serves
/main.csswith a redirect to the hashed version
Live reload
When you modify any .scss file during ddc serve:
- The file change is detected
- SCSS is recompiled
- A CSS-specific live reload message is sent
- The browser updates styles without a full page reload
This makes style iteration quick and avoids a full page reload for pure CSS changes.
Cache busting
The compiled CSS gets a content-based hash in its filename:
- Source:
sass/main.scss - Output:
main.0a3dec24.css(hash changes when content changes)
This means browsers can cache the CSS forever, but will always fetch new versions when you deploy changes.
URL rewriting
URLs in your CSS (for backgrounds, fonts, etc.) are automatically rewritten to point to the correct cache-busted paths:
// Input
. hero {
background : url ( '/images/hero.jpg' );
}
// Output (after compilation)
. hero {
background : url ( '/images/hero.dec0da12.jpg' );
}
Troubleshooting
SCSS not compiling
- Check that
sass/main.scssexists (exact name required) - Check the terminal for compilation errors
Styles not updating
- Hard refresh the browser (Cmd+Shift+R / Ctrl+Shift+R)
- Check that live reload is connected (look for WebSocket connection in browser dev tools)
- Try
ddc cleanto clear caches, then restartddc serve
Import errors
- Use
@use "filename"without the_prefix or.scssextension - Partials must be in the same
sass/directory