Merge branch 'cli-serde-default' into cli-config-library

This commit is contained in:
Evan Almloff committed 2023-11-10 16:26:58 -06:00
commit 5dc3486c53
9 files changed
+103 -117

No files matched your search

+2 -11
View File
@@ -5,10 +5,7 @@ use dioxus_core::Template;
use dioxus_html::HtmlCtx;
use dioxus_rsx::hot_reload::*;
use notify::{RecommendedWatcher, Watcher};
use std::{
path::PathBuf,
sync::{Arc, Mutex},
};
use std::sync::{Arc, Mutex};
use tokio::sync::broadcast::{self};
mod output;
@@ -26,13 +23,7 @@ async fn setup_file_watcher<F: Fn() -> Result<BuildResult> + Send + 'static>(
let mut last_update_time = chrono::Local::now().timestamp();
// file watcher: check file change
let allow_watch_path = config
.dioxus_config
.web
.watcher
.watch_path
.clone()
.unwrap_or_else(|| vec![PathBuf::from("src"), PathBuf::from("examples")]);
let allow_watch_path = config.dioxus_config.web.watcher.watch_path.clone();
let watcher_config = config.clone();
let mut watcher = notify::recommended_watcher(move |info: notify::Result<notify::Event>| {
+6 -14
View File
@@ -47,19 +47,13 @@ pub fn print_console_info(
} else {
"Default"
};
let url_rewrite = if config
.dioxus_config
.web
.watcher
.index_on_404
.unwrap_or(false)
{
let url_rewrite = if config.dioxus_config.web.watcher.index_on_404 {
"True"
} else {
"False"
};
let proxies = config.dioxus_config.web.proxy.as_ref();
let proxies = &config.dioxus_config.web.proxy;
if options.changed.is_empty() {
println!(
@@ -107,12 +101,10 @@ pub fn print_console_info(
println!();
println!("\t> Profile : {}", profile.green());
println!("\t> Hot Reload : {}", hot_reload.cyan());
if let Some(proxies) = proxies {
if !proxies.is_empty() {
println!("\t> Proxies :");
for proxy in proxies {
println!("\t\t- {}", proxy.backend.blue());
}
if !proxies.is_empty() {
println!("\t> Proxies :");
for proxy in proxies {
println!("\t\t- {}", proxy.backend.blue());
}
}
println!("\t> Index Template : {}", custom_html_file.green());
+3 -14
View File
@@ -262,12 +262,7 @@ async fn setup_router(
.override_response_header(HeaderName::from_static("cross-origin-opener-policy"), coop)
.and_then(
move |response: Response<ServeFileSystemResponseBody>| async move {
let response = if file_service_config
.dioxus_config
.web
.watcher
.index_on_404
.unwrap_or(false)
let response = if file_service_config.dioxus_config.web.watcher.index_on_404
&& response.status() == StatusCode::NOT_FOUND
{
let body = Full::from(
@@ -299,7 +294,7 @@ async fn setup_router(
let mut router = Router::new().route("/_dioxus/ws", get(ws_handler));
// Setup proxy
for proxy_config in config.dioxus_config.web.proxy.unwrap_or_default() {
for proxy_config in config.dioxus_config.web.proxy {
router = proxy::add_proxy(router, &proxy_config)?;
}
@@ -416,13 +411,7 @@ fn build(config: &CrateConfig, reload_tx: &Sender<()>) -> Result<BuildResult> {
let result = builder::build(config, true)?;
// change the websocket reload state to true;
// the page will auto-reload.
if config
.dioxus_config
.web
.watcher
.reload_html
.unwrap_or(false)
{
if config.dioxus_config.web.watcher.reload_html {
let _ = Serve::regen_dev_page(config);
}
let _ = reload_tx.send(());