Files
ottyl/tickets/028-fs-embed-static-bundling.md
T
2026-09-05 16:17:18 +01:00

1.5 KiB

028 — Bundle the webapp with fs-embed, drop --static-dir

Summary

fs-embed is already a Cargo.toml dependency but unused (grep -rn "fs_embed" src/ turns up nothing) — src/api.rs still serves the webapp via ServeDir/ServeFile pointed at a --static-dir CLI arg (src/main.rs:35), which requires shipping webapp/dist alongside the binary. Embed the built webapp into the binary instead so ottyl is a single self-contained executable.

Scope

  • Use fs-embed to embed webapp/dist at build time.
  • Wire the embedded filesystem into src/api.rs in place of the ServeDir::new(static_dir).fallback(ServeFile::new(index_html)) setup (src/api.rs:100-101), preserving the SPA fallback-to-index.html behavior.
  • Remove the --static-dir clap arg (src/main.rs:30-35) and its plumbing through api::router (src/api.rs:91, src/main.rs:108).
  • Update the test helper that builds a router against a temp static dir (src/api.rs:729-744) to match the new embedding approach.
  • webapp/dist must exist at cargo build time (i.e. the webapp build step stays a prerequisite) — document that in the README's build instructions if not already covered.

Acceptance criteria

  • cargo build (with webapp/dist present) produces a binary that serves the webapp with no --static-dir flag and no webapp/dist directory needed at runtime.
  • --static-dir no longer appears in --help output or Args.
  • Existing API tests pass against the embedded-filesystem router.

Depends on

None.