From 8eda67ecb203306e23866e0a22efd8707d6cd1bd Mon Sep 17 00:00:00 2001 From: Robin Tretter <25963632+rtretter@users.noreply.github.com> Date: Fri, 8 Mar 2024 21:54:03 +0100 Subject: [PATCH] added hot-reload as config option with default to true (#2024) --- examples/openid_connect_demo/Dioxus.toml | 3 +++ packages/cli-config/src/config.rs | 8 ++++++++ packages/cli/src/assets/dioxus.toml | 5 ++++- packages/cli/src/cli/serve.rs | 3 ++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/examples/openid_connect_demo/Dioxus.toml b/examples/openid_connect_demo/Dioxus.toml index 483dfe957..6ff23161e 100644 --- a/examples/openid_connect_demo/Dioxus.toml +++ b/examples/openid_connect_demo/Dioxus.toml @@ -14,6 +14,9 @@ out_dir = "dist" # resource (static) file folder asset_dir = "public" +# hot reload by default +hot_reload = true + [web.app] # HTML title tag content diff --git a/packages/cli-config/src/config.rs b/packages/cli-config/src/config.rs index 7ef92dcf0..7d391f28b 100644 --- a/packages/cli-config/src/config.rs +++ b/packages/cli-config/src/config.rs @@ -176,6 +176,7 @@ impl Default for DioxusConfig { default_platform: default_platform(), out_dir: out_dir_default(), asset_dir: asset_dir_default(), + hot_reload: hot_reload_default(), #[cfg(feature = "cli")] tools: Default::default(), @@ -226,6 +227,9 @@ pub struct ApplicationConfig { #[serde(default = "asset_dir_default")] pub asset_dir: PathBuf, + #[serde(default = "hot_reload_default")] + pub hot_reload: bool, + #[cfg(feature = "cli")] #[serde(default)] pub tools: std::collections::HashMap, @@ -242,6 +246,10 @@ fn default_platform() -> Platform { Platform::Web } +fn hot_reload_default() -> bool { + true +} + fn asset_dir_default() -> PathBuf { PathBuf::from("public") } diff --git a/packages/cli/src/assets/dioxus.toml b/packages/cli/src/assets/dioxus.toml index 892a6cdf8..ef66e47c4 100644 --- a/packages/cli/src/assets/dioxus.toml +++ b/packages/cli/src/assets/dioxus.toml @@ -14,6 +14,9 @@ out_dir = "dist" # resource (static) file folder asset_dir = "public" +# hot reload by default +hot_reload = true + [web.app] # HTML title tag content @@ -71,4 +74,4 @@ short_description = "An amazing dioxus application." # Bundle long description long_description = """ An amazing dioxus application. -""" \ No newline at end of file +""" diff --git a/packages/cli/src/cli/serve.rs b/packages/cli/src/cli/serve.rs index ac60d460e..4448e9b0b 100644 --- a/packages/cli/src/cli/serve.rs +++ b/packages/cli/src/cli/serve.rs @@ -19,7 +19,8 @@ impl Serve { let serve_cfg = self.serve.clone(); // change the relase state. - crate_config.with_hot_reload(self.serve.hot_reload); + let hot_reload = self.serve.hot_reload || crate_config.dioxus_config.application.hot_reload; + crate_config.with_hot_reload(hot_reload); crate_config.with_cross_origin_policy(self.serve.cross_origin_policy); crate_config.with_release(self.serve.release); crate_config.with_verbose(self.serve.verbose);