diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 7162e5b..7ca3e04 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -21,8 +21,17 @@ pub fn run() { .plugin(tauri_plugin_localhost::Builder::new(port).build()) .plugin(tauri_plugin_window_state::Builder::default().build()) .setup(move |app| { - let url = format!("http://localhost:{}", port).parse().unwrap(); - let window_url = WebviewUrl::External(url); + // Dev: use devUrl from tauri.conf.json (http://localhost:8080) to support HMR + #[cfg(debug_assertions)] + let window_url = WebviewUrl::App(Default::default()); + + // Release: tauri-plugin-localhost serves bundled frontend assets on this port + #[cfg(not(debug_assertions))] + let window_url = { + let url = format!("http://localhost:{}", port).parse().unwrap(); + WebviewUrl::External(url) + }; + WebviewWindowBuilder::new(app, "main".to_string(), window_url) .title("Cinny") .build()?;