Merge branch 'master' into master

This commit is contained in:
YuKun Liu authored and GitHub committed 2022-08-18 16:33:09 -07:00
commit 0e8414b40a
3 files changed
+57 -43

No files matched your search

+1 -1
View File
@@ -25,7 +25,7 @@ toml = "0.5.8"
fs_extra = "1.2.0" fs_extra = "1.2.0"
cargo_toml = "0.11.4" cargo_toml = "0.11.4"
futures = "0.3.21" 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" html_parser = "0.6.2"
binary-install = "0.0.2" binary-install = "0.0.2"
convert_case = "0.5.0" convert_case = "0.5.0"
+12 -9
View File
@@ -152,10 +152,7 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<BuildResult> {
if config.release == true { if config.release == true {
args.push("-Oz"); args.push("-Oz");
} }
binaryen.call( binaryen.call("wasm-opt", args)?;
"wasm-opt",
args,
)?;
} }
} }
} }
@@ -177,11 +174,11 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<BuildResult> {
let input_path = match sub.get("input") { let input_path = match sub.get("input") {
Some(val) => val.as_str().unwrap(), Some(val) => val.as_str().unwrap(),
None => "./public" None => "./public",
}; };
let config_path = match sub.get("config") { let config_path = match sub.get("config") {
Some(val) => val.as_str().unwrap(), Some(val) => val.as_str().unwrap(),
None => "./src/tailwind.config.js" None => "./src/tailwind.config.js",
}; };
let mut args = vec![ let mut args = vec![
"-i", "-i",
@@ -189,13 +186,13 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<BuildResult> {
"-o", "-o",
"dist/tailwind.css", "dist/tailwind.css",
"-c", "-c",
config_path config_path,
]; ];
if config.release == true { if config.release == true {
args.push("--minify"); args.push("--minify");
} }
tailwind.call("tailwindcss", args)?; tailwind.call("tailwindcss", args)?;
} }
} else { } else {
@@ -459,7 +456,13 @@ pub fn gen_page(config: &DioxusConfig, serve: bool) -> String {
&style.to_str().unwrap(), &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("<link rel=\"stylesheet\" href=\"tailwind.css\">\n"); style_str.push_str("<link rel=\"stylesheet\" href=\"tailwind.css\">\n");
} }
html = html.replace("{style_include}", &style_str); html = html.replace("{style_include}", &style_str);
+44 -33
View File
@@ -151,47 +151,58 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> {
} else { } else {
*last = last.split_at(end.column).0; *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 {
if needs_rebuild { match build_manager.rebuild() {
match build_manager.rebuild() { Ok(res) => {
Ok(res) => { print_console_info(
print_console_info( port,
port, &config,
&config, PrettierOptions {
PrettierOptions { changed: evt.paths,
changed: evt.paths, warnings: res.warnings,
warnings: res.warnings, elapsed_time: res.elapsed_time,
elapsed_time: res.elapsed_time, },
}, );
); }
} Err(err) => {
Err(err) => { log::error!("{}", err);
log::error!("{}", err); }
} }
} }
if !messages.is_empty() {
let _ = hot_reload_tx.send(SetManyRsxMessage(messages));
}
} }
if !messages.is_empty() { last_update_time = chrono::Local::now().timestamp();
let _ = hot_reload_tx.send(SetManyRsxMessage(messages));
}
} }
last_update_time = chrono::Local::now().timestamp(); },
} notify::Config::default(),
}) )
.unwrap(); .unwrap();
for sub_path in allow_watch_path { 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(); .unwrap();
for sub_path in allow_watch_path { for sub_path in allow_watch_path {