Release mode
Some checks failed
Rust Checks / checks (push) Failing after 4s

This commit is contained in:
Tipragot 2024-01-25 18:13:20 +00:00
parent ae1cc9cc8c
commit 53f2ac8ff8
2 changed files with 22 additions and 17 deletions

View file

@ -30,13 +30,7 @@ features = ["web"]
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
dioxus-fullstack = { version = "*", features = ["axum"] }
dioxus-cli = { version = "*", optional = true }
railwind = { version = "0.1.5", optional = true }
walkdir = { version = "2.4.0", optional = true }
regex = { version = "1.10.3", optional = true }
[features]
default = ["auto-build"]
auto-build = ["dep:dioxus-cli", "dep:railwind", "dep:walkdir", "dep:regex"]
[build-dependencies]
dioxus-cli = "*"
railwind = "0.1.5"
walkdir = "2.4.0"
regex = "1.10.3"

View file

@ -1,20 +1,22 @@
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
pub use dioxus::prelude::*;
pub use dioxus_fullstack::prelude::*;
#[cfg(all(not(target_arch = "wasm32"), feature = "auto-build"))]
#[cfg(all(not(target_arch = "wasm32"), debug_assertions))]
fn build_wasm() {
use dioxus_cli::CrateConfig;
use railwind::{CollectionOptions, SourceOptions};
use regex::Regex;
use std::path::Path;
use std::{env, fs, path::PathBuf};
use std::{fs, path::PathBuf};
use walkdir::WalkDir;
let project_folder = Path::new(env!("CARGO_MANIFEST_DIR"));
let output_folder = project_folder.join("web");
// Build WASM
let mut config = CrateConfig::new(None).unwrap();
let mut config = CrateConfig::new(Some(project_folder.to_path_buf())).unwrap();
config.release = true;
config.asset_dir = project_folder.join("assets");
config.out_dir = output_folder.clone();
@ -50,14 +52,12 @@ pub fn launch<
>(
component: Component<Props>,
) {
#[cfg(all(not(target_arch = "wasm32"), feature = "auto-build"))]
build_wasm();
#[cfg(target_arch = "wasm32")]
LaunchBuilder::new(component).launch();
#[cfg(all(not(target_arch = "wasm32"), feature = "auto-build"))]
#[cfg(all(not(target_arch = "wasm32"), debug_assertions))]
{
build_wasm();
let config = ServeConfigBuilder::new(component, Props::default())
.index_path(concat!(env!("CARGO_MANIFEST_DIR"), "/web/index.html"))
.assets_path(concat!(env!("CARGO_MANIFEST_DIR"), "/web"));
@ -65,4 +65,15 @@ pub fn launch<
.server_cfg(config)
.launch();
}
#[cfg(all(not(target_arch = "wasm32"), not(debug_assertions)))]
{
let config = ServeConfigBuilder::new(component, Props::default())
.index_path("web/index.html")
.assets_path("web");
LaunchBuilder::new(|cx| render!("Hello World"))
.server_cfg(config)
.addr(SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, 80)))
.launch();
}
}