sqzass.git

sqzass

~ A static site generator written in Rust
git clone https://github.com/debuman/sqzass.git

docs/content/features/dev-server.md (1981B)

      1 +++
      2 title = "Development server"
      3 description = "Serving from memory, rebuilds on change, and reloads that keep your place"
      4 weight = 40
      5 toc = true
      6 +++
      7 
      8 ```bash
      9 sqzass serve -i docs
     10 ```
     11 
     12 <http://127.0.0.1:3000>, rebuilding whenever anything in `content/`, `templates/`,
     13 `static/` or `i18n/` changes, or `sqzass.toml` itself. The output directory is
     14 deliberately not watched: a build that triggered on its own output would never
     15 stop rebuilding.
     16 
     17 | Flag | | |
     18 |---|---|---|
     19 | `-i`, `--input` | `.` | Site root. |
     20 | `-b`, `--bind` | `127.0.0.1` | Bind address. |
     21 | `-p`, `--port` | `3000` | Port. |
     22 | `--drafts` | | Include draft pages. |
     23 | `--base-url` | | Override `base_url`. |
     24 
     25 ## Nothing is written to disk
     26 
     27 The build goes into memory and is served from there. `public/` is not touched
     28 while the server runs.
     29 
     30 That is not an optimisation. A browser that requests a file mid-rebuild would
     31 otherwise get whatever bytes had been written so far, and the resulting
     32 half-page is the kind of bug you chase for an hour before realising it was not
     33 your code. Serving a build that is complete or not served at all removes the
     34 window entirely.
     35 
     36 ## Reloading
     37 
     38 The reload script is injected as the page is served, not written into the
     39 build, so the output stays byte-identical to what a production build produces.
     40 
     41 A change that touched only CSS swaps the stylesheet's `href` in place instead
     42 of reloading — the page does not move, and you keep your scroll position while
     43 you nudge a margin. Anything else reloads the page.
     44 
     45 ## When a build fails
     46 
     47 The error is shown in the browser rather than only in the terminal you may not
     48 be looking at, and the last good version stays served underneath. Fix the file,
     49 save, and the overlay goes away.
     50 
     51 ## It is not a production server
     52 
     53 No caching, no compression, no access control, no TLS. It binds to localhost by
     54 default for that reason. `--bind 0.0.0.0` will let a phone on your network see
     55 the site, which is useful and is as far as it should go.