feat: refined reload logs

This commit is contained in:
Valerio Ageno
2024-06-08 12:42:58 +02:00
parent 2e82dde2c3
commit 8728499f90
+14 -6
View File
@@ -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();