From 90e7463bb31f9ba9a190567a8f59146ff833619f Mon Sep 17 00:00:00 2001 From: crisqyxw Date: Fri, 21 Oct 2022 12:17:43 +0800 Subject: [PATCH 1/4] Update doc to avoid misunderstanding --- docs/src/configure.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/configure.md b/docs/src/configure.md index 97d4c9f55..ac922f5a6 100644 --- a/docs/src/configure.md +++ b/docs/src/configure.md @@ -25,7 +25,7 @@ We use `toml` to define some info for `dioxus` project. asset_dir = "public" ``` -### Application.Tool +### Application.Tools You can combine different tools with `dioxus`. @@ -168,4 +168,4 @@ style = [] # Javascript code file script = [] -``` \ No newline at end of file +``` From c2c4989483d797962c520aac744b5a49a0a23d11 Mon Sep 17 00:00:00 2001 From: MeiHui FAN Date: Mon, 24 Oct 2022 19:48:23 +0800 Subject: [PATCH 2/4] Why clean up the 'dist' directory when building for desktop? This can affect things like extra side generating css files. --- src/builder.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index 4cc3ece3f..de59373c0 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -284,12 +284,6 @@ pub fn build_desktop(config: &CrateConfig, is_serve: bool) -> Result<()> { } if output.status.success() { - // this code will clean the output dir. - // if using the serve, we will not clean the out_dir. - if config.out_dir.is_dir() && !is_serve { - remove_dir_all(&config.out_dir)?; - } - let release_type = match config.release { true => "release", false => "debug", From 029c0b23f4900fdd2b80e219f834eea4f805d3f2 Mon Sep 17 00:00:00 2001 From: MeiHui FAN Date: Mon, 24 Oct 2022 19:58:22 +0800 Subject: [PATCH 3/4] eliminate duplicate absolute path join --- src/cli/serve/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/serve/mod.rs b/src/cli/serve/mod.rs index 6619da53d..d99842fc4 100644 --- a/src/cli/serve/mod.rs +++ b/src/cli/serve/mod.rs @@ -49,7 +49,7 @@ impl Serve { if cfg!(windows) { file.set_extension("exe"); } - Command::new(crate_config.out_dir.join(file).to_str().unwrap()) + Command::new(file.to_str().unwrap()) .stdout(Stdio::inherit()) .output()?; } From 16935bded1462eb0daa88930ca49eb62fb22c078 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Sun, 30 Oct 2022 21:07:05 -0500 Subject: [PATCH 4/4] create out_dir if it doesn't exist on serve --- Cargo.lock | 52 ++++++++++++++++++++++++++++++++++++++++++++ src/cli/serve/mod.rs | 25 +++++++++++---------- 2 files changed, 65 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 568e80cf3..d1aaa1fc4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -554,6 +554,8 @@ dependencies = [ "clap", "colored 2.0.0", "convert_case", + "dioxus-core", + "dioxus-rsx", "dirs 4.0.0", "fern", "flate2", @@ -582,6 +584,38 @@ dependencies = [ "zip 0.6.2", ] +[[package]] +name = "dioxus-core" +version = "0.2.1" +source = "git+https://github.com/dioxuslabs/dioxus/#f89cd204557f09febebf1afc48f418ad6ebc5254" +dependencies = [ + "backtrace", + "bumpalo", + "dyn-clone", + "futures-channel", + "futures-util", + "indexmap", + "log", + "longest-increasing-subsequence", + "once_cell", + "rustc-hash", + "serde", + "slab", + "smallvec", +] + +[[package]] +name = "dioxus-rsx" +version = "0.0.0" +source = "git+https://github.com/dioxuslabs/dioxus/#f89cd204557f09febebf1afc48f418ad6ebc5254" +dependencies = [ + "dioxus-core", + "proc-macro2", + "quote", + "serde", + "syn", +] + [[package]] name = "dirs" version = "1.0.5" @@ -613,6 +647,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "dyn-clone" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" + [[package]] name = "encode_unicode" version = "0.3.6" @@ -1286,6 +1326,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "longest-increasing-subsequence" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3bd0dd2cd90571056fdb71f6275fada10131182f84899f4b2a916e565d81d86" + [[package]] name = "lru-cache" version = "0.1.2" @@ -1877,6 +1923,12 @@ version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustls" version = "0.20.6" diff --git a/src/cli/serve/mod.rs b/src/cli/serve/mod.rs index d99842fc4..841e72d10 100644 --- a/src/cli/serve/mod.rs +++ b/src/cli/serve/mod.rs @@ -1,5 +1,6 @@ use super::*; use std::{ + fs::create_dir_all, io::Write, path::PathBuf, process::{Command, Stdio}, @@ -71,19 +72,19 @@ impl Serve { pub fn regen_dev_page(crate_config: &CrateConfig) -> Result<()> { let serve_html = gen_page(&crate_config.dioxus_config, true); - let mut file = std::fs::File::create( + let dist_path = crate_config.crate_dir.join( crate_config - .crate_dir - .join( - crate_config - .dioxus_config - .application - .out_dir - .clone() - .unwrap_or_else(|| PathBuf::from("dist")), - ) - .join("index.html"), - )?; + .dioxus_config + .application + .out_dir + .clone() + .unwrap_or_else(|| PathBuf::from("dist")), + ); + if !dist_path.is_dir() { + create_dir_all(&dist_path)?; + } + let index_path = dist_path.join("index.html"); + let mut file = std::fs::File::create(index_path)?; file.write_all(serve_html.as_bytes())?; Ok(())