spawn hot reloading in a seperate thread

This commit is contained in:
Evan Almloff committed 2023-05-01 17:34:30 -05:00
1 parent 126ed2f9b8
commit 064bee4a9f
13 files changed
+106 -65

No files matched your search

@@ -13,15 +13,9 @@ dioxus-server = { path = "../../" }
axum = { version = "0.6.12", optional = true }
tokio = { version = "1.27.0", features = ["full"], optional = true }
serde = "1.0.159"
execute = "0.2.12"
[features]
default = ["web"]
ssr = ["axum", "tokio", "dioxus-server/axum"]
web = ["dioxus-web"]
[profile.release]
lto = true
panic = "abort"
opt-level = 3
strip = true
codegen-units = 1
@@ -19,6 +19,19 @@ fn main() {
);
#[cfg(feature = "ssr")]
{
// Start hot reloading
hot_reload_init!(dioxus_hot_reload::Config::new().with_rebuild_callback(|| {
execute::shell("dioxus build --features web")
.spawn()
.unwrap()
.wait()
.unwrap();
execute::shell("cargo run --features ssr --no-default-features")
.spawn()
.unwrap();
true
}));
PostServerData::register().unwrap();
GetServerData::register().unwrap();
tokio::runtime::Runtime::new()
@@ -65,7 +78,7 @@ fn app(cx: Scope<AppProps>) -> Element {
}
}
},
"Run a server function"
"Run a server function! testing1234"
}
"Server said: {text}"
})