You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: support optimized Bazel builds for Tauri desktop app (#38)
Tauri's generate_context!() proc macro generates struct literals whose
shape depends on cfg(debug_assertions) in the host config, but the code
compiles in the target config. With -c opt the target loses
debug_assertions while the host (fastbuild from .bazelrc) keeps them,
causing missing type/field errors.
Add --config=opt to .bazelrc that sets both compilation_mode and
host_compilation_mode to opt. Gate devtools menu item and handler behind
#[cfg(debug_assertions)] since those APIs are unavailable in release.
-`cargo test -p crab_city_desktop` — run unit tests
43
43
-`cd packages/crab_city_desktop && cargo tauri dev --config tauri.dev.conf.json` — launch desktop app with embedded server (auto-starts Vite dev server)
44
-
-`bazel build //packages/crab_city_desktop:macos_app` — build macOS `.app` bundle with embedded server
**Dev workflow** (single terminal): `cd packages/crab_city_desktop && cargo tauri dev --config tauri.dev.conf.json` — the Tauri app starts an embedded server in-process, and Vite's dev proxy discovers it automatically via the `daemon.port` file. The `--config` flag merges `tauri.dev.conf.json` (devUrl + beforeDevCommand) into the base config. The base `tauri.conf.json` has no dev URL — production builds never reference external dev servers.
Copy file name to clipboardExpand all lines: packages/crab_city_desktop/CLAUDE.md
+7-2Lines changed: 7 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,9 @@ Tauri's `generate_context!()` proc macro writes cache files to `OUT_DIR` during
41
41
42
42
Frontend assets (`frontendDist`) are brotli-compressed into `$OUT_DIR/tauri-codegen-assets/{blake3_hash}.{ext}`. The `precreate_frontend_cache()` function in `build.rs` replicates this exactly so the proc macro's write is a no-op in Bazel.
43
43
44
-
Additionally, `ResolvedCommand` has `#[cfg(debug_assertions)]` fields. Bazel compiles proc macros in exec config (default: `opt`, no debug_assertions) but targets in `fastbuild` (with debug_assertions). This mismatch is fixed by `--host_compilation_mode=fastbuild` in `.bazelrc`.
44
+
Additionally, `ResolvedCommand` has `#[cfg(debug_assertions)]` fields. Bazel compiles proc macros in exec config (default: `opt`, no debug_assertions) but targets in `fastbuild` (with debug_assertions). This mismatch is fixed by a Starlark transition in `tauri_transition.bzl` that forces `host_compilation_mode` to match `compilation_mode`. The `tauri_binary` and `tauri_test` wrapper rules apply this transition — the raw `rust_binary` and `rust_test` targets are tagged `manual` and should not be built directly.
45
+
46
+
DevTools APIs (`is_devtools_open()`, `open_devtools()`, `close_devtools()`) are only available with `debug_assertions`. The devtools menu item and handler are gated behind `#[cfg(debug_assertions)]`.
45
47
46
48
## Dev Workflow
47
49
@@ -80,7 +82,10 @@ When the external server dies, the health monitor navigates back to `tauri://loc
The `tauri_binary` wrapper rule applies a Starlark transition that keeps `host_compilation_mode` in sync with `compilation_mode`, so both `-c opt` and `--config=opt` work correctly.
90
+
86
91
Produces `CrabCity.app` with the Tauri binary (which includes the embedded server) in `Contents/MacOS/`. No sidecar binary needed. The `macos_app` rule in `macos_app.bzl` uses a tree artifact (directory output) to assemble the bundle structure. Code signing and notarization are deferred to when public distribution is needed.
0 commit comments