How to not run sidecar http service when running in dev mode, like yarn tauri dev
?
#6453
-
I'm bundling an http service as a sidecar. During local development, I don't need the sidecar to run. Right now I've got:
Is there a way to say instead "if release mode" or "if not development mode"?
|
Beta Was this translation helpful? Give feedback.
Answered by
FabianLars
Mar 15, 2023
Replies: 1 comment 3 replies
-
you can check for the fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![get_port])
.setup(|app| {
let window = app.get_window("main").unwrap();
#[cfg(not(dev))]
tauri::async_runtime::spawn(async move {
let (mut rx, mut child) = Command::new_sidecar("http-api")
.expect("failed to setup `http-api` sidecar")
.spawn()
.expect("Failed to spawn packaged node");
});
Ok(())
})
.plugin(tauri_plugin_log::Builder::default().targets([
LogTarget::LogDir,
LogTarget::Stdout,
LogTarget::Webview,
]).build())
.run(tauri::generate_context!())
.expect("error while running tauri application");
} the |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
djeikyb
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you can check for the
dev
cfg flag like this for example: