fix: enable/disable hot reload (#2737)
This commit is contained in:
1 parent
0e84d00d9c
commit
67c0f1c5f0
1 file changed
+3
-1
@@ -55,6 +55,8 @@ pub async fn serve_all(serve: Serve, dioxus_crate: DioxusCrate) -> Result<()> {
|
|||||||
let mut watcher = Watcher::start(&serve, &dioxus_crate);
|
let mut watcher = Watcher::start(&serve, &dioxus_crate);
|
||||||
let mut screen = Output::start(&serve).expect("Failed to open terminal logger");
|
let mut screen = Output::start(&serve).expect("Failed to open terminal logger");
|
||||||
|
|
||||||
|
let is_hot_reload = serve.server_arguments.hot_reload.unwrap_or(true);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
// Make sure we don't hog the CPU: these loop { select! {} } blocks can starve the executor
|
// Make sure we don't hog the CPU: these loop { select! {} } blocks can starve the executor
|
||||||
yield_now().await;
|
yield_now().await;
|
||||||
@@ -65,7 +67,7 @@ pub async fn serve_all(serve: Serve, dioxus_crate: DioxusCrate) -> Result<()> {
|
|||||||
// And then wait for any updates before redrawing
|
// And then wait for any updates before redrawing
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
// rebuild the project or hotreload it
|
// rebuild the project or hotreload it
|
||||||
_ = watcher.wait() => {
|
_ = watcher.wait(), if is_hot_reload => {
|
||||||
if !watcher.pending_changes() {
|
if !watcher.pending_changes() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user