mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-17 14:18:27 +00:00
feat: commit console log
This commit is contained in:
parent
81b712ec0b
commit
61c06ea598
5 changed files with 26 additions and 22 deletions
|
@ -13,7 +13,7 @@ use std::{
|
|||
};
|
||||
use wasm_bindgen_cli_support::Bindgen;
|
||||
|
||||
pub fn build(config: &CrateConfig) -> Result<()> {
|
||||
pub fn build(config: &CrateConfig, quiet: bool) -> Result<()> {
|
||||
// [1] Build the project with cargo, generating a wasm32-unknown-unknown target (is there a more specific, better target to leverage?)
|
||||
// [2] Generate the appropriate build folders
|
||||
// [3] Wasm-bindgen the .wasm fiile, and move it into the {builddir}/modules/xxxx/xxxx_bg.wasm
|
||||
|
@ -52,6 +52,10 @@ pub fn build(config: &CrateConfig) -> Result<()> {
|
|||
cmd.arg("--verbose");
|
||||
}
|
||||
|
||||
if quiet {
|
||||
cmd.arg("--quiet");
|
||||
}
|
||||
|
||||
if config.custom_profile.is_some() {
|
||||
let custom_profile = config.custom_profile.as_ref().unwrap();
|
||||
cmd.arg("--profile");
|
||||
|
|
|
@ -34,7 +34,7 @@ impl Build {
|
|||
|
||||
match platform.as_str() {
|
||||
"web" => {
|
||||
crate::builder::build(&crate_config)?;
|
||||
crate::builder::build(&crate_config, false)?;
|
||||
}
|
||||
"desktop" => {
|
||||
crate::builder::build_desktop(&crate_config, false)?;
|
||||
|
|
|
@ -40,7 +40,7 @@ impl Serve {
|
|||
|
||||
match platform.as_str() {
|
||||
"web" => {
|
||||
crate::builder::build(&crate_config)?;
|
||||
crate::builder::build(&crate_config, false)?;
|
||||
}
|
||||
"desktop" => {
|
||||
crate::builder::build_desktop(&crate_config, true)?;
|
||||
|
|
|
@ -154,7 +154,7 @@ pub async fn hot_reload_handler(
|
|||
log::error!("parse error:\n--> at {}:{}:{}\n\t{:?}", parse_error.location.file_path, parse_error.location.line, parse_error.location.column, parse_error.message);
|
||||
},
|
||||
Error::RecompileRequiredError(_) => {
|
||||
if let Err(err) = state.build_manager.build(){
|
||||
if let Err(err) = state.build_manager.rebuild(){
|
||||
log::error!("{}", err);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,9 +27,9 @@ pub struct BuildManager {
|
|||
}
|
||||
|
||||
impl BuildManager {
|
||||
fn build(&self) -> Result<()> {
|
||||
log::info!("🪁 Rebuild code");
|
||||
builder::build(&self.config)?;
|
||||
fn rebuild(&self) -> Result<()> {
|
||||
log::info!("🪁 Rebuild project");
|
||||
builder::build(&self.config, true)?;
|
||||
// change the websocket reload state to true;
|
||||
// the page will auto-reload.
|
||||
if self
|
||||
|
@ -158,7 +158,7 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> {
|
|||
}
|
||||
if needs_rebuild {
|
||||
log::info!("reload required");
|
||||
if let Err(err) = build_manager.build() {
|
||||
if let Err(err) = build_manager.rebuild() {
|
||||
log::error!("{}", err);
|
||||
}
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> {
|
|||
if info.is_ok() {
|
||||
let info = info.unwrap();
|
||||
if chrono::Local::now().timestamp() > last_update_time {
|
||||
match build_manager.build() {
|
||||
match build_manager.rebuild() {
|
||||
Ok(_) => {
|
||||
last_update_time = chrono::Local::now().timestamp();
|
||||
print_rebuild_info(info.paths);
|
||||
|
@ -433,19 +433,19 @@ fn print_console_info(port: u16, config: &CrateConfig) {
|
|||
}
|
||||
|
||||
fn print_rebuild_info(paths: Vec<PathBuf>) {
|
||||
print!(
|
||||
"{}",
|
||||
String::from_utf8_lossy(
|
||||
&Command::new(if cfg!(target_os = "windows") {
|
||||
"cls"
|
||||
} else {
|
||||
"clear"
|
||||
})
|
||||
.output()
|
||||
.unwrap()
|
||||
.stdout
|
||||
)
|
||||
);
|
||||
// print!(
|
||||
// "{}",
|
||||
// String::from_utf8_lossy(
|
||||
// &Command::new(if cfg!(target_os = "windows") {
|
||||
// "cls"
|
||||
// } else {
|
||||
// "clear"
|
||||
// })
|
||||
// .output()
|
||||
// .unwrap()
|
||||
// .stdout
|
||||
// )
|
||||
// );
|
||||
|
||||
for path in paths {
|
||||
let path = path.strip_prefix(crate::crate_root().unwrap()).unwrap().to_path_buf();
|
||||
|
|
Loading…
Add table
Reference in a new issue