diff --git a/crates/tuono/src/watch.rs b/crates/tuono/src/watch.rs index 23cbf228..f3152fb8 100644 --- a/crates/tuono/src/watch.rs +++ b/crates/tuono/src/watch.rs @@ -57,22 +57,30 @@ pub async fn watch() -> Result<()> { println!("\nDevelopment app ready at http://localhost:3000/"); let wx = Watchexec::new(move |mut action| { + let mut should_reload = false; + for event in action.events.iter() { for path in event.paths() { if path.0.to_string_lossy().ends_with(".rs") // Either tsx and jsx || path.0.to_string_lossy().ends_with("sx") { - println!("Reloading..."); - run_server.stop(); - build_ssr_bundle.stop(); - build_ssr_bundle.start(); - bundle_axum_source().expect("Failed to bunlde rust source"); - run_server.start(); + should_reload = true } } } + if should_reload { + println!("Reloading..."); + run_server.stop(); + build_ssr_bundle.stop(); + build_ssr_bundle.start(); + bundle_axum_source().expect("Failed to bunlde rust source"); + run_server.start(); + println!("Ready!"); + should_reload = false; + } + // if Ctrl-C is received, quit if action.signals().any(|sig| sig == Signal::Interrupt) { action.quit();