Skip to content

How to not run sidecar http service when running in dev mode, like yarn tauri dev? #6453

Answered by FabianLars
djeikyb asked this question in Q&A
Discussion options

You must be logged in to vote

you can check for the dev cfg flag like this for example:

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,

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@djeikyb
Comment options

@FabianLars
Comment options

@djeikyb
Comment options

Answer selected by djeikyb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants