diff --git a/Cargo.toml b/Cargo.toml index 8b2a3904e..2690def1b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ toml = "0.5.8" fs_extra = "1.2.0" cargo_toml = "0.11.4" futures = "0.3.21" -notify = { version = "5.0.0-pre.13", features = ["serde"] } +notify = { version = "5.0.0-pre.16", features = ["serde"] } html_parser = "0.6.2" binary-install = "0.0.2" convert_case = "0.5.0" diff --git a/src/builder.rs b/src/builder.rs index 5cb994a65..88b6f43b4 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -152,10 +152,7 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result { if config.release == true { args.push("-Oz"); } - binaryen.call( - "wasm-opt", - args, - )?; + binaryen.call("wasm-opt", args)?; } } } @@ -177,11 +174,11 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result { let input_path = match sub.get("input") { Some(val) => val.as_str().unwrap(), - None => "./public" + None => "./public", }; let config_path = match sub.get("config") { Some(val) => val.as_str().unwrap(), - None => "./src/tailwind.config.js" + None => "./src/tailwind.config.js", }; let mut args = vec![ "-i", @@ -189,13 +186,13 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result { "-o", "dist/tailwind.css", "-c", - config_path + config_path, ]; if config.release == true { args.push("--minify"); } - + tailwind.call("tailwindcss", args)?; } } else { @@ -459,7 +456,13 @@ pub fn gen_page(config: &DioxusConfig, serve: bool) -> String { &style.to_str().unwrap(), )) } - if config.application.tools.clone().unwrap_or_default().contains_key("tailwindcss") { + if config + .application + .tools + .clone() + .unwrap_or_default() + .contains_key("tailwindcss") + { style_str.push_str("\n"); } html = html.replace("{style_include}", &style_str); diff --git a/src/server/mod.rs b/src/server/mod.rs index 2298960ff..bf7d5dfbb 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -151,47 +151,58 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> { } else { *last = last.split_at(end.column).0; } + if let Some(last) = lines.last_mut() { + // if there is only one line the start index of last line will be the start of the rsx!, not the start of the line + if start.line == end.line { + *last = last + .split_at(end.column - start.column) + .0; + } else { + *last = last.split_at(end.column).0; + } + } + let rsx = lines.join("\n"); + messages.push(SetRsxMessage { + location: hr, + new_text: rsx, + }); } - let rsx = lines.join("\n"); - messages.push(SetRsxMessage { - location: hr, - new_text: rsx, - }); } } } + } else { + // if this is a new file, rebuild the project + *last_file_rebuild = FileMap::new(crate_dir.clone()); } - } else { - // if this is a new file, rebuild the project - *last_file_rebuild = FileMap::new(crate_dir.clone()); } } - } - if needs_rebuild { - match build_manager.rebuild() { - Ok(res) => { - print_console_info( - port, - &config, - PrettierOptions { - changed: evt.paths, - warnings: res.warnings, - elapsed_time: res.elapsed_time, - }, - ); - } - Err(err) => { - log::error!("{}", err); + if needs_rebuild { + match build_manager.rebuild() { + Ok(res) => { + print_console_info( + port, + &config, + PrettierOptions { + changed: evt.paths, + warnings: res.warnings, + elapsed_time: res.elapsed_time, + }, + ); + } + Err(err) => { + log::error!("{}", err); + } } } + if !messages.is_empty() { + let _ = hot_reload_tx.send(SetManyRsxMessage(messages)); + } } - if !messages.is_empty() { - let _ = hot_reload_tx.send(SetManyRsxMessage(messages)); - } + last_update_time = chrono::Local::now().timestamp(); } - last_update_time = chrono::Local::now().timestamp(); - } - }) + }, + notify::Config::default(), + ) .unwrap(); for sub_path in allow_watch_path { @@ -321,11 +332,11 @@ pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> { }, ); } - Err(e) => log::error!("{}", e), } } - } - }) + }, + notify::Config::default(), + ) .unwrap(); for sub_path in allow_watch_path {