FIx:
- asset hotreloading for desktop, - asset dir for dxserve on desktop, - extend features with platform
This commit is contained in:
12 files changed
+101
-33
No files matched your search
+18
-10
@@ -15,6 +15,7 @@ use std::{
|
||||
io::Read,
|
||||
panic,
|
||||
path::PathBuf,
|
||||
process::Command,
|
||||
time::Duration,
|
||||
};
|
||||
use wasm_bindgen_cli_support::Bindgen;
|
||||
@@ -98,16 +99,17 @@ pub fn build_web(
|
||||
// [1] Build the .wasm module
|
||||
log::info!("🚅 Running build command...");
|
||||
|
||||
let wasm_check_command = std::process::Command::new("rustup")
|
||||
.args(["show"])
|
||||
.output()?;
|
||||
|
||||
let wasm_check_output = String::from_utf8(wasm_check_command.stdout).unwrap();
|
||||
if !wasm_check_output.contains("wasm32-unknown-unknown") {
|
||||
log::info!("wasm32-unknown-unknown target not detected, installing..");
|
||||
let _ = std::process::Command::new("rustup")
|
||||
.args(["target", "add", "wasm32-unknown-unknown"])
|
||||
.output()?;
|
||||
// If the user has rustup, we can check if the wasm32-unknown-unknown target is installed
|
||||
// Otherwise we can just assume it is installed - which i snot great...
|
||||
// Eventually we can poke at the errors and let the user know they need to install the target
|
||||
if let Ok(wasm_check_command) = Command::new("rustup").args(["show"]).output() {
|
||||
let wasm_check_output = String::from_utf8(wasm_check_command.stdout).unwrap();
|
||||
if !wasm_check_output.contains("wasm32-unknown-unknown") {
|
||||
log::info!("wasm32-unknown-unknown target not detected, installing..");
|
||||
let _ = Command::new("rustup")
|
||||
.args(["target", "add", "wasm32-unknown-unknown"])
|
||||
.output()?;
|
||||
}
|
||||
}
|
||||
|
||||
let cmd = subprocess::Exec::cmd("cargo")
|
||||
@@ -333,6 +335,12 @@ pub fn build_desktop(
|
||||
let _manganis_support = ManganisSupportGuard::default();
|
||||
let _guard = AssetConfigDropGuard::new();
|
||||
|
||||
// set the asset dir via cli args
|
||||
env::set_var(
|
||||
"DIOXUS_ASSET_DIR",
|
||||
config.asset_dir().canonicalize().unwrap(),
|
||||
);
|
||||
|
||||
let mut cmd = subprocess::Exec::cmd("cargo")
|
||||
.set_rust_flags(rust_flags)
|
||||
.env("CARGO_TARGET_DIR", &config.target_dir)
|
||||
|
||||
@@ -50,6 +50,7 @@ impl Build {
|
||||
}
|
||||
|
||||
crate_config.set_cargo_args(self.build.cargo_args.clone());
|
||||
crate_config.extend_with_platform(platform);
|
||||
|
||||
// #[cfg(feature = "plugin")]
|
||||
// let _ = crate::plugin::PluginManager::on_build_start(&crate_config, &platform);
|
||||
|
||||
@@ -82,6 +82,9 @@ impl Bundle {
|
||||
}
|
||||
|
||||
crate_config.set_cargo_args(self.build.cargo_args);
|
||||
if let Some(platform) = self.build.platform {
|
||||
crate_config.extend_with_platform(platform);
|
||||
}
|
||||
|
||||
// build the desktop app
|
||||
// Since the `bundle()` function is only run for the desktop platform,
|
||||
|
||||
@@ -178,7 +178,7 @@ pub struct ConfigOptsBundle {
|
||||
|
||||
/// Build platform: support Web & Desktop [default: "default_platform"]
|
||||
#[clap(long)]
|
||||
pub platform: Option<String>,
|
||||
pub platform: Option<Platform>,
|
||||
|
||||
/// Space separated list of features to activate
|
||||
#[clap(long)]
|
||||
|
||||
@@ -60,6 +60,7 @@ impl Serve {
|
||||
}
|
||||
|
||||
let platform = platform.unwrap_or(crate_config.dioxus_config.application.default_platform);
|
||||
crate_config.extend_with_platform(platform);
|
||||
|
||||
// start the develop server
|
||||
use server::{desktop, fullstack, web};
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/79236386")]
|
||||
#![doc(html_favicon_url = "https://avatars.githubusercontent.com/u/79236386")]
|
||||
|
||||
pub const DIOXUS_CLI_VERSION: &str = "0.4.1";
|
||||
|
||||
mod assets;
|
||||
pub mod builder;
|
||||
pub mod server;
|
||||
|
||||
@@ -46,7 +46,7 @@ pub fn print_console_info(
|
||||
let custom_html_file = if crate_root.join("index.html").is_file() {
|
||||
"Custom [index.html]"
|
||||
} else {
|
||||
"Default"
|
||||
"None"
|
||||
};
|
||||
let url_rewrite = if config.dioxus_config.web.watcher.index_on_404 {
|
||||
"True"
|
||||
@@ -58,9 +58,9 @@ pub fn print_console_info(
|
||||
|
||||
if options.changed.is_empty() {
|
||||
println!(
|
||||
"{} @ v{} [{}] \n",
|
||||
"{} @ v{} [{}]",
|
||||
"Dioxus".bold().green(),
|
||||
crate::DIOXUS_CLI_VERSION,
|
||||
clap::crate_version!(),
|
||||
chrono::Local::now().format("%H:%M:%S").to_string().dimmed()
|
||||
);
|
||||
} else {
|
||||
@@ -79,40 +79,50 @@ pub fn print_console_info(
|
||||
if let Some(WebServerInfo { ip, port }) = web_info {
|
||||
if config.dioxus_config.web.https.enabled == Some(true) {
|
||||
println!(
|
||||
"\t> Local : {}",
|
||||
" > Local address: {}",
|
||||
format!("https://localhost:{}/", port).blue()
|
||||
);
|
||||
println!(
|
||||
"\t> Network : {}",
|
||||
" > Network address: {}",
|
||||
format!("https://{}:{}/", ip, port).blue()
|
||||
);
|
||||
println!("\t> HTTPS : {}", "Enabled".to_string().green());
|
||||
println!(" > HTTPS: {}", "Enabled".to_string().green());
|
||||
} else {
|
||||
println!(
|
||||
"\t> Local : {}",
|
||||
" > Local address: {}",
|
||||
format!("http://localhost:{}/", port).blue()
|
||||
);
|
||||
println!(
|
||||
"\t> Network : {}",
|
||||
" > Network address: {}",
|
||||
format!("http://{}:{}/", ip, port).blue()
|
||||
);
|
||||
println!("\t> HTTPS : {}", "Disabled".to_string().red());
|
||||
println!(" > HTTPS status: {}", "Disabled".to_string().red());
|
||||
}
|
||||
}
|
||||
println!();
|
||||
println!("\t> Profile : {}", profile.green());
|
||||
println!("\t> Hot Reload : {}", hot_reload.cyan());
|
||||
|
||||
println!(" > Hot Reload Mode: {}", hot_reload.cyan());
|
||||
if !proxies.is_empty() {
|
||||
println!("\t> Proxies :");
|
||||
println!(" > Proxies :");
|
||||
for proxy in proxies {
|
||||
println!("\t\t- {}", proxy.backend.blue());
|
||||
println!(" - {}", proxy.backend.blue());
|
||||
}
|
||||
}
|
||||
println!("\t> Index Template : {}", custom_html_file.green());
|
||||
println!("\t> URL Rewrite [index_on_404] : {}", url_rewrite.purple());
|
||||
println!(" > Custom index.html: {}", custom_html_file.green());
|
||||
println!(" > Serve index.html on 404: {}", url_rewrite.purple());
|
||||
println!();
|
||||
println!(
|
||||
"\t> Build Time Use : {} millis",
|
||||
" > Build Features: [ {} ]",
|
||||
config
|
||||
.features
|
||||
.clone()
|
||||
.unwrap_or_default()
|
||||
.join(", ")
|
||||
.green()
|
||||
);
|
||||
println!(" > Build Profile: {}", profile.green());
|
||||
println!(
|
||||
" > Build took: {} millis",
|
||||
options.elapsed_time.to_string().green().bold()
|
||||
);
|
||||
println!();
|
||||
|
||||
Reference in new issue
Block a user