source · Rust

Build

crates/vak-desktop/build.rs
Raw
1.3 KB33 linesSnapshot ed4ab258
  1. 1//! Tauri codegen, plus the same stale-bundle guard `vak-server` uses.
  2. 2//!
  3. 3//! The client lives in `crates/vak-client-ui` and builds twice — `dist/`
  4. 4//! for this shell, `dist-web/` for the copy `vak-server` embeds under
  5. 5//! `/app` (docs/design/48-web-client.md). This crate ships `dist/`.
  6. 6//!
  7. 7//! `dist/` is gitignored rather than committed, so it can never be
  8. 8//! *shipped* stale the way the admin bundle once was — but a local `cargo
  9. 9//! build` after a UI edit still produces an app serving the previous
  10. 10//! frontend, silently. Same trap, same check.
  11. 11
  12. 12include!("../../scripts/ui_bundle_check.rs");
  13. 13
  14. 14const UI: &str = "../vak-client-ui";
  15. 15const DIST: &str = "dist";
  16. 16
  17. 17fn main() {
  18. 18 println!("cargo:rerun-if-changed={UI}/src");
  19. 19 println!("cargo:rerun-if-changed={UI}/index.html");
  20. 20
  21. 21 if let Err(problem) = check_bundle_matches_source(Path::new(UI), DIST) {
  22. 22 let problem = format!("crates/vak-client-ui/{problem}");
  23. 23 // `cargo::error` is the supported way for a build script to fail the
  24. 24 // build with a readable message; `panic!` would bury it under a
  25. 25 // backtrace the reader does not need.
  26. 26 println!("cargo::error={problem}");
  27. 27 println!("cargo::error=Run `npm run build` in crates/vak-client-ui.");
  28. 28 std::process::exit(1);
  29. 29 }
  30. 30
  31. 31 tauri_build::build()
  32. 32}
  33. 33