Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Backend/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ fn is_flatpak_build() -> bool {
)
}

fn is_tauri_dev() -> bool {
matches!(env::var("DEP_TAURI_DEV").as_deref(), Ok("true"))
}

fn main() {
// Base config path (in the Backend crate)
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR"));
Expand Down Expand Up @@ -39,6 +43,22 @@ fn main() {
}
}

// The app should only ever point at a dev server when running `cargo tauri dev`.
// In all other cases (including `cargo build`, `cargo run`, `cargo tauri build`, Flatpak, CI),
// we must ship/load the prebuilt frontend assets from `frontendDist`.
let strip_dev_server = !is_tauri_dev() || is_flatpak_build();

// Non-dev builds should never point at the dev server.
// We build the frontend ahead of time and ship it as production assets.
if strip_dev_server {
if let Some(build) = json.get_mut("build") {
if let Some(build_obj) = build.as_object_mut() {
build_obj.remove("devUrl");
build_obj.remove("beforeDevCommand");
}
}
}

// Flatpak apps update via Flatpak, not the in-app updater.
if is_flatpak_build() {
if let Some(plugins) = json.get_mut("plugins") {
Expand Down
Loading