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

@@ -16,15 +16,9 @@ tokio = { version = "1.27.0", features = ["full"], optional = true }
serde = "1.0.159"
tower-http = { version = "0.4.0", features = ["fs"], optional = true }
http = { version = "0.2.9", optional = true }
execute = "0.2.12"
[features]
default = ["web"]
ssr = ["axum", "tokio", "dioxus-server/axum", "tower-http", "http"]
web = ["dioxus-web", "dioxus-router/web"]
[profile.release]
lto = true
panic = "abort"
opt-level = 3
strip = true
codegen-units = 1
@@ -20,6 +20,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
}));
use axum::extract::State;
PostServerData::register().unwrap();
GetServerData::register().unwrap();