Răsfoiți Sursa

Merge branch 'master' into add-file-data-drag-event

Jonathan Kelley 1 an în urmă
părinte
comite
5ccbeeab46
49 a modificat fișierele cu 1188 adăugiri și 888 ștergeri
  1. 2 0
      Cargo.toml
  2. 4 0
      packages/cli-config/.gitignore
  3. 26 0
      packages/cli-config/Cargo.toml
  4. 5 0
      packages/cli-config/README.md
  5. 260 0
      packages/cli-config/src/bundle.rs
  6. 32 11
      packages/cli-config/src/cargo.rs
  7. 492 0
      packages/cli-config/src/config.rs
  8. 58 0
      packages/cli-config/src/lib.rs
  9. 2 1
      packages/cli/Cargo.toml
  10. 60 0
      packages/cli/src/assets.rs
  11. 20 75
      packages/cli/src/builder.rs
  12. 1 1
      packages/cli/src/cli/autoformat.rs
  13. 4 10
      packages/cli/src/cli/build.rs
  14. 5 4
      packages/cli/src/cli/bundle.rs
  15. 1 15
      packages/cli/src/cli/cfg.rs
  16. 1 1
      packages/cli/src/cli/check.rs
  17. 2 6
      packages/cli/src/cli/clean.rs
  18. 7 2
      packages/cli/src/cli/config.rs
  19. 2 1
      packages/cli/src/cli/mod.rs
  20. 9 15
      packages/cli/src/cli/serve.rs
  21. 0 608
      packages/cli/src/config.rs
  22. 18 0
      packages/cli/src/error.rs
  23. 1 6
      packages/cli/src/lib.rs
  24. 1 0
      packages/cli/src/main.rs
  25. 7 4
      packages/cli/src/server/desktop/mod.rs
  26. 5 2
      packages/cli/src/server/fullstack/mod.rs
  27. 4 12
      packages/cli/src/server/mod.rs
  28. 9 16
      packages/cli/src/server/output.rs
  29. 18 15
      packages/cli/src/server/web/mod.rs
  30. 2 1
      packages/cli/src/server/web/proxy.rs
  31. 1 0
      packages/desktop/Cargo.toml
  32. 2 2
      packages/desktop/src/app.rs
  33. 6 1
      packages/desktop/src/config.rs
  34. 15 21
      packages/fullstack/Cargo.toml
  35. 1 2
      packages/fullstack/examples/axum-hello-world/Cargo.toml
  36. 1 2
      packages/fullstack/examples/salvo-hello-world/Cargo.toml
  37. 1 2
      packages/fullstack/examples/warp-hello-world/Cargo.toml
  38. 1 1
      packages/fullstack/src/html_storage/deserialize.rs
  39. 8 5
      packages/fullstack/src/html_storage/mod.rs
  40. 7 6
      packages/fullstack/src/html_storage/serialize.rs
  41. 6 3
      packages/fullstack/src/render.rs
  42. 8 7
      packages/html/Cargo.toml
  43. 2 4
      packages/router/Cargo.toml
  44. 1 2
      packages/router/examples/simple_routes.rs
  45. 27 17
      packages/router/src/history/liveview.rs
  46. 24 0
      packages/router/src/history/web.rs
  47. 16 3
      packages/router/src/router_cfg.rs
  48. 2 2
      packages/rsx/Cargo.toml
  49. 1 2
      packages/ssr/Cargo.toml

+ 2 - 0
Cargo.toml

@@ -4,6 +4,7 @@ members = [
     "packages/dioxus",
     "packages/core",
     "packages/cli",
+    "packages/cli-config",
     "packages/core-macro",
     "packages/router-macro",
     "packages/extension",
@@ -79,6 +80,7 @@ dioxus-native-core = { path = "packages/native-core", version = "0.4.0" }
 dioxus-native-core-macro = { path = "packages/native-core-macro", version = "0.4.0" }
 rsx-rosetta = { path = "packages/rsx-rosetta", version = "0.4.0" }
 dioxus-signals = { path = "packages/signals" }
+dioxus-cli-config = { path = "packages/cli-config", version = "0.4.1" }
 generational-box = { path = "packages/generational-box", version = "0.4.3" }
 dioxus-hot-reload = { path = "packages/hot-reload", version = "0.4.0" }
 dioxus-fullstack = { path = "packages/fullstack", version = "0.4.1"  }

+ 4 - 0
packages/cli-config/.gitignore

@@ -0,0 +1,4 @@
+/target
+Cargo.lock
+.DS_Store
+.idea/

+ 26 - 0
packages/cli-config/Cargo.toml

@@ -0,0 +1,26 @@
+[package]
+name = "dioxus-cli-config"
+version = "0.4.1"
+authors = ["Jonathan Kelley"]
+edition = "2021"
+description = "Configuration for the Dioxus CLI"
+repository = "https://github.com/DioxusLabs/dioxus/"
+license = "MIT OR Apache-2.0"
+keywords = ["react", "gui", "cli", "dioxus", "wasm"]
+
+[dependencies]
+clap = { version = "4.2", features = ["derive"], optional = true }
+serde = { version = "1.0.136", features = ["derive"] }
+serde_json = "1.0.79"
+toml = { version = "0.5.8", optional = true }
+cargo_toml = { version = "0.16.0", optional = true }
+once_cell = "1.18.0"
+tracing.workspace = true
+
+# bundling
+tauri-bundler = { version = "=1.4.0", features = ["native-tls-vendored"], optional = true }
+tauri-utils = { version = "=1.5.*", optional = true }
+
+[features]
+default = []
+cli = ["tauri-bundler", "tauri-utils", "clap", "toml", "cargo_toml"]

+ 5 - 0
packages/cli-config/README.md

@@ -0,0 +1,5 @@
+<div style="text-align: center">
+  <h1>📦✨ Dioxus CLI Configuration</h1>
+</div>
+
+The **dioxus-cli-config** contains the configuration for the **dioxus-cli**.

+ 260 - 0
packages/cli-config/src/bundle.rs

@@ -0,0 +1,260 @@
+use serde::{Deserialize, Serialize};
+use std::collections::HashMap;
+use std::path::PathBuf;
+
+#[derive(Debug, Clone, Serialize, Deserialize, Default)]
+pub struct BundleConfig {
+    pub identifier: Option<String>,
+    pub publisher: Option<String>,
+    pub icon: Option<Vec<String>>,
+    pub resources: Option<Vec<String>>,
+    pub copyright: Option<String>,
+    pub category: Option<String>,
+    pub short_description: Option<String>,
+    pub long_description: Option<String>,
+    pub external_bin: Option<Vec<String>>,
+    pub deb: Option<DebianSettings>,
+    pub macos: Option<MacOsSettings>,
+    pub windows: Option<WindowsSettings>,
+}
+
+#[cfg(feature = "cli")]
+impl From<BundleConfig> for tauri_bundler::BundleSettings {
+    fn from(val: BundleConfig) -> Self {
+        tauri_bundler::BundleSettings {
+            identifier: val.identifier,
+            publisher: val.publisher,
+            icon: val.icon,
+            resources: val.resources,
+            copyright: val.copyright,
+            category: val.category.and_then(|c| c.parse().ok()),
+            short_description: val.short_description,
+            long_description: val.long_description,
+            external_bin: val.external_bin,
+            deb: val.deb.map(Into::into).unwrap_or_default(),
+            macos: val.macos.map(Into::into).unwrap_or_default(),
+            windows: val.windows.map(Into::into).unwrap_or_default(),
+            ..Default::default()
+        }
+    }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, Default)]
+pub struct DebianSettings {
+    pub depends: Option<Vec<String>>,
+    pub files: HashMap<PathBuf, PathBuf>,
+    pub nsis: Option<NsisSettings>,
+}
+
+#[cfg(feature = "cli")]
+impl From<DebianSettings> for tauri_bundler::DebianSettings {
+    fn from(val: DebianSettings) -> Self {
+        tauri_bundler::DebianSettings {
+            depends: val.depends,
+            files: val.files,
+            desktop_template: None,
+        }
+    }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, Default)]
+pub struct WixSettings {
+    pub language: Vec<(String, Option<PathBuf>)>,
+    pub template: Option<PathBuf>,
+    pub fragment_paths: Vec<PathBuf>,
+    pub component_group_refs: Vec<String>,
+    pub component_refs: Vec<String>,
+    pub feature_group_refs: Vec<String>,
+    pub feature_refs: Vec<String>,
+    pub merge_refs: Vec<String>,
+    pub skip_webview_install: bool,
+    pub license: Option<PathBuf>,
+    pub enable_elevated_update_task: bool,
+    pub banner_path: Option<PathBuf>,
+    pub dialog_image_path: Option<PathBuf>,
+    pub fips_compliant: bool,
+}
+
+#[cfg(feature = "cli")]
+impl From<WixSettings> for tauri_bundler::WixSettings {
+    fn from(val: WixSettings) -> Self {
+        tauri_bundler::WixSettings {
+            language: tauri_bundler::bundle::WixLanguage({
+                let mut languages: Vec<_> = val
+                    .language
+                    .iter()
+                    .map(|l| {
+                        (
+                            l.0.clone(),
+                            tauri_bundler::bundle::WixLanguageConfig {
+                                locale_path: l.1.clone(),
+                            },
+                        )
+                    })
+                    .collect();
+                if languages.is_empty() {
+                    languages.push(("en-US".into(), Default::default()));
+                }
+                languages
+            }),
+            template: val.template,
+            fragment_paths: val.fragment_paths,
+            component_group_refs: val.component_group_refs,
+            component_refs: val.component_refs,
+            feature_group_refs: val.feature_group_refs,
+            feature_refs: val.feature_refs,
+            merge_refs: val.merge_refs,
+            skip_webview_install: val.skip_webview_install,
+            license: val.license,
+            enable_elevated_update_task: val.enable_elevated_update_task,
+            banner_path: val.banner_path,
+            dialog_image_path: val.dialog_image_path,
+            fips_compliant: val.fips_compliant,
+        }
+    }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, Default)]
+pub struct MacOsSettings {
+    pub frameworks: Option<Vec<String>>,
+    pub minimum_system_version: Option<String>,
+    pub license: Option<String>,
+    pub exception_domain: Option<String>,
+    pub signing_identity: Option<String>,
+    pub provider_short_name: Option<String>,
+    pub entitlements: Option<String>,
+    pub info_plist_path: Option<PathBuf>,
+}
+
+#[cfg(feature = "cli")]
+impl From<MacOsSettings> for tauri_bundler::MacOsSettings {
+    fn from(val: MacOsSettings) -> Self {
+        tauri_bundler::MacOsSettings {
+            frameworks: val.frameworks,
+            minimum_system_version: val.minimum_system_version,
+            license: val.license,
+            exception_domain: val.exception_domain,
+            signing_identity: val.signing_identity,
+            provider_short_name: val.provider_short_name,
+            entitlements: val.entitlements,
+            info_plist_path: val.info_plist_path,
+        }
+    }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct WindowsSettings {
+    pub digest_algorithm: Option<String>,
+    pub certificate_thumbprint: Option<String>,
+    pub timestamp_url: Option<String>,
+    pub tsp: bool,
+    pub wix: Option<WixSettings>,
+    pub icon_path: Option<PathBuf>,
+    pub webview_install_mode: WebviewInstallMode,
+    pub webview_fixed_runtime_path: Option<PathBuf>,
+    pub allow_downgrades: bool,
+    pub nsis: Option<NsisSettings>,
+}
+
+#[cfg(feature = "cli")]
+impl From<WindowsSettings> for tauri_bundler::WindowsSettings {
+    fn from(val: WindowsSettings) -> Self {
+        tauri_bundler::WindowsSettings {
+            digest_algorithm: val.digest_algorithm,
+            certificate_thumbprint: val.certificate_thumbprint,
+            timestamp_url: val.timestamp_url,
+            tsp: val.tsp,
+            wix: val.wix.map(Into::into),
+            icon_path: val.icon_path.unwrap_or("icons/icon.ico".into()),
+            webview_install_mode: val.webview_install_mode.into(),
+            webview_fixed_runtime_path: val.webview_fixed_runtime_path,
+            allow_downgrades: val.allow_downgrades,
+            nsis: val.nsis.map(Into::into),
+        }
+    }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct NsisSettings {
+    pub template: Option<PathBuf>,
+    pub license: Option<PathBuf>,
+    pub header_image: Option<PathBuf>,
+    pub sidebar_image: Option<PathBuf>,
+    pub installer_icon: Option<PathBuf>,
+    pub install_mode: NSISInstallerMode,
+    pub languages: Option<Vec<String>>,
+    pub custom_language_files: Option<HashMap<String, PathBuf>>,
+    pub display_language_selector: bool,
+}
+
+#[cfg(feature = "cli")]
+impl From<NsisSettings> for tauri_bundler::NsisSettings {
+    fn from(val: NsisSettings) -> Self {
+        tauri_bundler::NsisSettings {
+            license: val.license,
+            header_image: val.header_image,
+            sidebar_image: val.sidebar_image,
+            installer_icon: val.installer_icon,
+            install_mode: val.install_mode.into(),
+            languages: val.languages,
+            display_language_selector: val.display_language_selector,
+            custom_language_files: None,
+            template: None,
+            compression: None,
+        }
+    }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub enum NSISInstallerMode {
+    CurrentUser,
+    PerMachine,
+    Both,
+}
+
+#[cfg(feature = "cli")]
+impl From<NSISInstallerMode> for tauri_utils::config::NSISInstallerMode {
+    fn from(val: NSISInstallerMode) -> Self {
+        match val {
+            NSISInstallerMode::CurrentUser => tauri_utils::config::NSISInstallerMode::CurrentUser,
+            NSISInstallerMode::PerMachine => tauri_utils::config::NSISInstallerMode::PerMachine,
+            NSISInstallerMode::Both => tauri_utils::config::NSISInstallerMode::Both,
+        }
+    }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub enum WebviewInstallMode {
+    Skip,
+    DownloadBootstrapper { silent: bool },
+    EmbedBootstrapper { silent: bool },
+    OfflineInstaller { silent: bool },
+    FixedRuntime { path: PathBuf },
+}
+
+#[cfg(feature = "cli")]
+impl WebviewInstallMode {
+    fn into(self) -> tauri_utils::config::WebviewInstallMode {
+        match self {
+            Self::Skip => tauri_utils::config::WebviewInstallMode::Skip,
+            Self::DownloadBootstrapper { silent } => {
+                tauri_utils::config::WebviewInstallMode::DownloadBootstrapper { silent }
+            }
+            Self::EmbedBootstrapper { silent } => {
+                tauri_utils::config::WebviewInstallMode::EmbedBootstrapper { silent }
+            }
+            Self::OfflineInstaller { silent } => {
+                tauri_utils::config::WebviewInstallMode::OfflineInstaller { silent }
+            }
+            Self::FixedRuntime { path } => {
+                tauri_utils::config::WebviewInstallMode::FixedRuntime { path }
+            }
+        }
+    }
+}
+
+impl Default for WebviewInstallMode {
+    fn default() -> Self {
+        Self::OfflineInstaller { silent: false }
+    }
+}

+ 32 - 11
packages/cli/src/cargo.rs → packages/cli-config/src/cargo.rs

@@ -1,12 +1,33 @@
 //! Utilities for working with cargo and rust files
-use crate::error::{Error, Result};
+use std::error::Error;
 use std::{
-    env, fs,
+    env,
+    fmt::{Display, Formatter},
+    fs,
     path::{Path, PathBuf},
     process::Command,
     str,
 };
 
+#[derive(Debug, Clone)]
+pub struct CargoError {
+    msg: String,
+}
+
+impl CargoError {
+    pub fn new(msg: String) -> Self {
+        Self { msg }
+    }
+}
+
+impl Display for CargoError {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        write!(f, "CargoError: {}", self.msg)
+    }
+}
+
+impl Error for CargoError {}
+
 /// How many parent folders are searched for a `Cargo.toml`
 const MAX_ANCESTORS: u32 = 10;
 
@@ -19,7 +40,7 @@ pub struct Metadata {
 /// Returns the root of the crate that the command is run from
 ///
 /// If the command is run from the workspace root, this will return the top-level Cargo.toml
-pub fn crate_root() -> Result<PathBuf> {
+pub fn crate_root() -> Result<PathBuf, CargoError> {
     // From the current directory we work our way up, looking for `Cargo.toml`
     env::current_dir()
         .ok()
@@ -35,7 +56,7 @@ pub fn crate_root() -> Result<PathBuf> {
             None
         })
         .ok_or_else(|| {
-            Error::CargoError("Failed to find directory containing Cargo.toml".to_string())
+            CargoError::new("Failed to find directory containing Cargo.toml".to_string())
         })
 }
 
@@ -53,11 +74,11 @@ fn contains_manifest(path: &Path) -> bool {
 impl Metadata {
     /// Returns the struct filled from `cargo metadata` output
     /// TODO @Jon, find a different way that doesn't rely on the cargo metadata command (it's slow)
-    pub fn get() -> Result<Self> {
+    pub fn get() -> Result<Self, CargoError> {
         let output = Command::new("cargo")
             .args(["metadata"])
             .output()
-            .map_err(|_| Error::CargoError("Manifset".to_string()))?;
+            .map_err(|_| CargoError::new("Manifset".to_string()))?;
 
         if !output.status.success() {
             let mut msg = str::from_utf8(&output.stderr).unwrap().trim();
@@ -65,22 +86,22 @@ impl Metadata {
                 msg = &msg[7..];
             }
 
-            return Err(Error::CargoError(msg.to_string()));
+            return Err(CargoError::new(msg.to_string()));
         }
 
         let stdout = str::from_utf8(&output.stdout).unwrap();
         if let Some(line) = stdout.lines().next() {
             let meta: serde_json::Value = serde_json::from_str(line)
-                .map_err(|_| Error::CargoError("InvalidOutput".to_string()))?;
+                .map_err(|_| CargoError::new("InvalidOutput".to_string()))?;
 
             let workspace_root = meta["workspace_root"]
                 .as_str()
-                .ok_or_else(|| Error::CargoError("InvalidOutput".to_string()))?
+                .ok_or_else(|| CargoError::new("InvalidOutput".to_string()))?
                 .into();
 
             let target_directory = meta["target_directory"]
                 .as_str()
-                .ok_or_else(|| Error::CargoError("InvalidOutput".to_string()))?
+                .ok_or_else(|| CargoError::new("InvalidOutput".to_string()))?
                 .into();
 
             return Ok(Self {
@@ -89,6 +110,6 @@ impl Metadata {
             });
         }
 
-        Err(Error::CargoError("InvalidOutput".to_string()))
+        Err(CargoError::new("InvalidOutput".to_string()))
     }
 }

+ 492 - 0
packages/cli-config/src/config.rs

@@ -0,0 +1,492 @@
+use crate::BundleConfig;
+use crate::CargoError;
+use core::fmt::{Display, Formatter};
+use serde::{Deserialize, Serialize};
+use std::path::PathBuf;
+
+#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Debug)]
+#[cfg_attr(feature = "cli", derive(clap::ValueEnum))]
+pub enum Platform {
+    #[cfg_attr(feature = "cli", clap(name = "web"))]
+    #[serde(rename = "web")]
+    Web,
+    #[cfg_attr(feature = "cli", clap(name = "desktop"))]
+    #[serde(rename = "desktop")]
+    Desktop,
+    #[cfg_attr(feature = "cli", clap(name = "fullstack"))]
+    #[serde(rename = "fullstack")]
+    Fullstack,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct DioxusConfig {
+    pub application: ApplicationConfig,
+
+    pub web: WebConfig,
+
+    #[serde(default)]
+    pub bundle: BundleConfig,
+
+    #[cfg(feature = "cli")]
+    #[serde(default = "default_plugin")]
+    pub plugin: toml::Value,
+}
+
+#[cfg(feature = "cli")]
+fn default_plugin() -> toml::Value {
+    toml::Value::Boolean(true)
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct LoadDioxusConfigError {
+    location: String,
+    error: String,
+}
+
+impl std::fmt::Display for LoadDioxusConfigError {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        write!(f, "{} {}", self.location, self.error)
+    }
+}
+
+impl std::error::Error for LoadDioxusConfigError {}
+
+#[derive(Debug)]
+pub enum CrateConfigError {
+    Cargo(CargoError),
+    Io(std::io::Error),
+    #[cfg(feature = "cli")]
+    Toml(toml::de::Error),
+    LoadDioxusConfig(LoadDioxusConfigError),
+}
+
+impl From<CargoError> for CrateConfigError {
+    fn from(err: CargoError) -> Self {
+        Self::Cargo(err)
+    }
+}
+
+impl From<std::io::Error> for CrateConfigError {
+    fn from(err: std::io::Error) -> Self {
+        Self::Io(err)
+    }
+}
+
+#[cfg(feature = "cli")]
+impl From<toml::de::Error> for CrateConfigError {
+    fn from(err: toml::de::Error) -> Self {
+        Self::Toml(err)
+    }
+}
+
+impl From<LoadDioxusConfigError> for CrateConfigError {
+    fn from(err: LoadDioxusConfigError) -> Self {
+        Self::LoadDioxusConfig(err)
+    }
+}
+
+impl Display for CrateConfigError {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        match self {
+            Self::Cargo(err) => write!(f, "{}", err),
+            Self::Io(err) => write!(f, "{}", err),
+            #[cfg(feature = "cli")]
+            Self::Toml(err) => write!(f, "{}", err),
+            Self::LoadDioxusConfig(err) => write!(f, "{}", err),
+        }
+    }
+}
+
+impl std::error::Error for CrateConfigError {}
+
+impl DioxusConfig {
+    #[cfg(feature = "cli")]
+    /// Load the dioxus config from a path
+    pub fn load(bin: Option<PathBuf>) -> Result<Option<DioxusConfig>, CrateConfigError> {
+        let crate_dir = crate::cargo::crate_root();
+
+        let crate_dir = match crate_dir {
+            Ok(dir) => {
+                if let Some(bin) = bin {
+                    dir.join(bin)
+                } else {
+                    dir
+                }
+            }
+            Err(_) => return Ok(None),
+        };
+        let crate_dir = crate_dir.as_path();
+
+        let Some(dioxus_conf_file) = acquire_dioxus_toml(crate_dir) else {
+            return Ok(None);
+        };
+
+        let dioxus_conf_file = dioxus_conf_file.as_path();
+        let cfg = toml::from_str::<DioxusConfig>(&std::fs::read_to_string(dioxus_conf_file)?)
+            .map_err(|err| {
+                let error_location = dioxus_conf_file
+                    .strip_prefix(crate_dir)
+                    .unwrap_or(dioxus_conf_file)
+                    .display();
+                CrateConfigError::LoadDioxusConfig(LoadDioxusConfigError {
+                    location: error_location.to_string(),
+                    error: err.to_string(),
+                })
+            })
+            .map(Some);
+        match cfg {
+            Ok(Some(mut cfg)) => {
+                let name = cfg.application.name.clone();
+                if cfg.bundle.identifier.is_none() {
+                    cfg.bundle.identifier = Some(format!("io.github.{name}"));
+                }
+                if cfg.bundle.publisher.is_none() {
+                    cfg.bundle.publisher = Some(name);
+                }
+                Ok(Some(cfg))
+            }
+            cfg => cfg,
+        }
+    }
+}
+
+#[cfg(feature = "cli")]
+fn acquire_dioxus_toml(dir: &std::path::Path) -> Option<PathBuf> {
+    // prefer uppercase
+    let uppercase_conf = dir.join("Dioxus.toml");
+    if uppercase_conf.is_file() {
+        return Some(uppercase_conf);
+    }
+
+    // lowercase is fine too
+    let lowercase_conf = dir.join("dioxus.toml");
+    if lowercase_conf.is_file() {
+        return Some(lowercase_conf);
+    }
+
+    None
+}
+
+impl Default for DioxusConfig {
+    fn default() -> Self {
+        let name = default_name();
+        Self {
+            application: ApplicationConfig {
+                name: name.clone(),
+                default_platform: default_platform(),
+                out_dir: out_dir_default(),
+                asset_dir: asset_dir_default(),
+
+                #[cfg(feature = "cli")]
+                tools: Default::default(),
+
+                sub_package: None,
+            },
+            web: WebConfig {
+                app: WebAppConfig {
+                    title: default_title(),
+                    base_path: None,
+                },
+                proxy: vec![],
+                watcher: Default::default(),
+                resource: WebResourceConfig {
+                    dev: WebDevResourceConfig {
+                        style: vec![],
+                        script: vec![],
+                    },
+                    style: Some(vec![]),
+                    script: Some(vec![]),
+                },
+                https: WebHttpsConfig {
+                    enabled: None,
+                    mkcert: None,
+                    key_path: None,
+                    cert_path: None,
+                },
+            },
+            bundle: BundleConfig {
+                identifier: Some(format!("io.github.{name}")),
+                publisher: Some(name),
+                ..Default::default()
+            },
+            #[cfg(feature = "cli")]
+            plugin: toml::Value::Table(toml::map::Map::new()),
+        }
+    }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct ApplicationConfig {
+    #[serde(default = "default_name")]
+    pub name: String,
+    #[serde(default = "default_platform")]
+    pub default_platform: Platform,
+    #[serde(default = "out_dir_default")]
+    pub out_dir: PathBuf,
+    #[serde(default = "asset_dir_default")]
+    pub asset_dir: PathBuf,
+
+    #[cfg(feature = "cli")]
+    #[serde(default)]
+    pub tools: std::collections::HashMap<String, toml::Value>,
+
+    #[serde(default)]
+    pub sub_package: Option<String>,
+}
+
+fn default_name() -> String {
+    "name".into()
+}
+
+fn default_platform() -> Platform {
+    Platform::Web
+}
+
+fn asset_dir_default() -> PathBuf {
+    PathBuf::from("public")
+}
+
+fn out_dir_default() -> PathBuf {
+    PathBuf::from("dist")
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct WebConfig {
+    #[serde(default)]
+    pub app: WebAppConfig,
+    #[serde(default)]
+    pub proxy: Vec<WebProxyConfig>,
+    #[serde(default)]
+    pub watcher: WebWatcherConfig,
+    #[serde(default)]
+    pub resource: WebResourceConfig,
+    #[serde(default)]
+    pub https: WebHttpsConfig,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct WebAppConfig {
+    #[serde(default = "default_title")]
+    pub title: String,
+    pub base_path: Option<String>,
+}
+
+impl Default for WebAppConfig {
+    fn default() -> Self {
+        Self {
+            title: default_title(),
+            base_path: None,
+        }
+    }
+}
+
+fn default_title() -> String {
+    "dioxus | ⛺".into()
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct WebProxyConfig {
+    pub backend: String,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct WebWatcherConfig {
+    #[serde(default = "watch_path_default")]
+    pub watch_path: Vec<PathBuf>,
+    #[serde(default)]
+    pub reload_html: bool,
+    #[serde(default = "true_bool")]
+    pub index_on_404: bool,
+}
+
+impl Default for WebWatcherConfig {
+    fn default() -> Self {
+        Self {
+            watch_path: watch_path_default(),
+            reload_html: false,
+            index_on_404: true,
+        }
+    }
+}
+
+fn watch_path_default() -> Vec<PathBuf> {
+    vec![PathBuf::from("src"), PathBuf::from("examples")]
+}
+
+#[derive(Default, Debug, Clone, Serialize, Deserialize)]
+pub struct WebResourceConfig {
+    pub dev: WebDevResourceConfig,
+    pub style: Option<Vec<PathBuf>>,
+    pub script: Option<Vec<PathBuf>>,
+}
+
+#[derive(Default, Debug, Clone, Serialize, Deserialize)]
+pub struct WebDevResourceConfig {
+    #[serde(default)]
+    pub style: Vec<PathBuf>,
+    #[serde(default)]
+    pub script: Vec<PathBuf>,
+}
+
+#[derive(Debug, Default, Clone, Serialize, Deserialize)]
+pub struct WebHttpsConfig {
+    pub enabled: Option<bool>,
+    pub mkcert: Option<bool>,
+    pub key_path: Option<String>,
+    pub cert_path: Option<String>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct CrateConfig {
+    pub out_dir: PathBuf,
+    pub crate_dir: PathBuf,
+    pub workspace_dir: PathBuf,
+    pub target_dir: PathBuf,
+    pub asset_dir: PathBuf,
+    #[cfg(feature = "cli")]
+    pub manifest: cargo_toml::Manifest<cargo_toml::Value>,
+    pub executable: ExecutableType,
+    pub dioxus_config: DioxusConfig,
+    pub release: bool,
+    pub hot_reload: bool,
+    pub cross_origin_policy: bool,
+    pub verbose: bool,
+    pub custom_profile: Option<String>,
+    pub features: Option<Vec<String>>,
+    pub target: Option<String>,
+    pub cargo_args: Vec<String>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub enum ExecutableType {
+    Binary(String),
+    Lib(String),
+    Example(String),
+}
+
+impl CrateConfig {
+    #[cfg(feature = "cli")]
+    pub fn new(bin: Option<PathBuf>) -> Result<Self, CrateConfigError> {
+        let dioxus_config = DioxusConfig::load(bin.clone())?.unwrap_or_default();
+
+        let crate_root = crate::crate_root()?;
+
+        let crate_dir = if let Some(package) = &dioxus_config.application.sub_package {
+            crate_root.join(package)
+        } else if let Some(bin) = bin {
+            crate_root.join(bin)
+        } else {
+            crate_root
+        };
+
+        let meta = crate::Metadata::get()?;
+        let workspace_dir = meta.workspace_root;
+        let target_dir = meta.target_directory;
+
+        let out_dir = crate_dir.join(&dioxus_config.application.out_dir);
+
+        let cargo_def = &crate_dir.join("Cargo.toml");
+
+        let asset_dir = crate_dir.join(&dioxus_config.application.asset_dir);
+
+        let manifest = cargo_toml::Manifest::from_path(cargo_def).unwrap();
+
+        let mut output_filename = String::from("dioxus_app");
+        if let Some(package) = &manifest.package.as_ref() {
+            output_filename = match &package.default_run {
+                Some(default_run_target) => default_run_target.to_owned(),
+                None => manifest
+                    .bin
+                    .iter()
+                    .find(|b| b.name == manifest.package.as_ref().map(|pkg| pkg.name.clone()))
+                    .or(manifest
+                        .bin
+                        .iter()
+                        .find(|b| b.path == Some("src/main.rs".to_owned())))
+                    .or(manifest.bin.first())
+                    .or(manifest.lib.as_ref())
+                    .and_then(|prod| prod.name.clone())
+                    .unwrap_or(String::from("dioxus_app")),
+            };
+        }
+
+        let executable = ExecutableType::Binary(output_filename);
+
+        let release = false;
+        let hot_reload = false;
+        let verbose = false;
+        let custom_profile = None;
+        let features = None;
+        let target = None;
+        let cargo_args = vec![];
+
+        Ok(Self {
+            out_dir,
+            crate_dir,
+            workspace_dir,
+            target_dir,
+            asset_dir,
+            #[cfg(feature = "cli")]
+            manifest,
+            executable,
+            release,
+            dioxus_config,
+            hot_reload,
+            cross_origin_policy: false,
+            custom_profile,
+            features,
+            verbose,
+            target,
+            cargo_args,
+        })
+    }
+
+    pub fn as_example(&mut self, example_name: String) -> &mut Self {
+        self.executable = ExecutableType::Example(example_name);
+        self
+    }
+
+    pub fn with_release(&mut self, release: bool) -> &mut Self {
+        self.release = release;
+        self
+    }
+
+    pub fn with_hot_reload(&mut self, hot_reload: bool) -> &mut Self {
+        self.hot_reload = hot_reload;
+        self
+    }
+
+    pub fn with_cross_origin_policy(&mut self, cross_origin_policy: bool) -> &mut Self {
+        self.cross_origin_policy = cross_origin_policy;
+        self
+    }
+
+    pub fn with_verbose(&mut self, verbose: bool) -> &mut Self {
+        self.verbose = verbose;
+        self
+    }
+
+    pub fn set_profile(&mut self, profile: String) -> &mut Self {
+        self.custom_profile = Some(profile);
+        self
+    }
+
+    pub fn set_features(&mut self, features: Vec<String>) -> &mut Self {
+        self.features = Some(features);
+        self
+    }
+
+    pub fn set_target(&mut self, target: String) -> &mut Self {
+        self.target = Some(target);
+        self
+    }
+
+    pub fn set_cargo_args(&mut self, cargo_args: Vec<String>) -> &mut Self {
+        self.cargo_args = cargo_args;
+        self
+    }
+}
+
+fn true_bool() -> bool {
+    true
+}

+ 58 - 0
packages/cli-config/src/lib.rs

@@ -0,0 +1,58 @@
+#![doc = include_str!("../README.md")]
+#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/79236386")]
+#![doc(html_favicon_url = "https://avatars.githubusercontent.com/u/79236386")]
+
+mod config;
+pub use config::*;
+mod bundle;
+pub use bundle::*;
+mod cargo;
+pub use cargo::*;
+
+#[doc(hidden)]
+pub mod __private {
+    use crate::CrateConfig;
+
+    pub const CONFIG_ENV: &str = "DIOXUS_CONFIG";
+
+    pub fn save_config(config: &CrateConfig) -> CrateConfigDropGuard {
+        std::env::set_var(CONFIG_ENV, serde_json::to_string(config).unwrap());
+        CrateConfigDropGuard
+    }
+
+    /// A guard that removes the config from the environment when dropped.
+    pub struct CrateConfigDropGuard;
+
+    impl Drop for CrateConfigDropGuard {
+        fn drop(&mut self) {
+            std::env::remove_var(CONFIG_ENV);
+        }
+    }
+}
+
+/// An error that occurs when the dioxus CLI was not used to build the application.
+#[derive(Debug)]
+pub struct DioxusCLINotUsed;
+
+impl std::fmt::Display for DioxusCLINotUsed {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        f.write_str("dioxus CLI was not used to build the application")
+    }
+}
+
+impl std::error::Error for DioxusCLINotUsed {}
+
+/// The current crate's configuration.
+pub static CURRENT_CONFIG: once_cell::sync::Lazy<
+    Result<crate::config::CrateConfig, DioxusCLINotUsed>,
+> = once_cell::sync::Lazy::new(|| {
+    CURRENT_CONFIG_JSON
+        .and_then(|config| serde_json::from_str(config).ok())
+        .ok_or_else(|| {
+            tracing::error!("A library is trying to access the crate's configuration, but the dioxus CLI was not used to build the application.");
+            DioxusCLINotUsed
+    })
+});
+
+/// The current crate's configuration.
+pub const CURRENT_CONFIG_JSON: Option<&str> = std::option_env!("DIOXUS_CONFIG");

+ 2 - 1
packages/cli/Cargo.toml

@@ -14,6 +14,7 @@ clap = { version = "4.2", features = ["derive"] }
 thiserror = { workspace = true }
 wasm-bindgen-cli-support = "0.2"
 colored = "2.0.0"
+dioxus-cli-config = { workspace = true, features = ["cli"] }
 
 # features
 log = "0.4.14"
@@ -75,7 +76,7 @@ toml_edit = "0.19.11"
 tauri-bundler = { version = "=1.4.*", features = ["native-tls-vendored"] }
 tauri-utils = "=1.5.*"
 
-manganis-cli-support= { git = "https://github.com/DioxusLabs/collect-assets", features = ["webp", "html"] }
+manganis-cli-support = { git = "https://github.com/DioxusLabs/collect-assets", features = ["webp", "html"] }
 
 dioxus-autofmt = { workspace = true }
 dioxus-check = { workspace = true }

+ 60 - 0
packages/cli/src/assets.rs

@@ -0,0 +1,60 @@
+use std::{fs::File, io::Write, path::PathBuf};
+
+use crate::Result;
+use dioxus_cli_config::CrateConfig;
+use manganis_cli_support::{AssetManifest, AssetManifestExt};
+
+pub fn asset_manifest(crate_config: &CrateConfig) -> AssetManifest {
+    AssetManifest::load_from_path(
+        crate_config.crate_dir.join("Cargo.toml"),
+        crate_config.workspace_dir.join("Cargo.lock"),
+    )
+}
+
+/// Create a head file that contains all of the imports for assets that the user project uses
+pub fn create_assets_head(config: &CrateConfig) -> Result<()> {
+    let manifest = asset_manifest(config);
+    let mut file = File::create(config.out_dir.join("__assets_head.html"))?;
+    file.write_all(manifest.head().as_bytes())?;
+    Ok(())
+}
+
+/// Process any assets collected from the binary
+pub(crate) fn process_assets(config: &CrateConfig) -> anyhow::Result<()> {
+    let manifest = asset_manifest(config);
+
+    let static_asset_output_dir = PathBuf::from(
+        config
+            .dioxus_config
+            .web
+            .app
+            .base_path
+            .clone()
+            .unwrap_or_default(),
+    );
+    let static_asset_output_dir = config.out_dir.join(static_asset_output_dir);
+
+    manifest.copy_static_assets_to(static_asset_output_dir)?;
+
+    Ok(())
+}
+
+/// A guard that sets up the environment for the web renderer to compile in. This guard sets the location that assets will be served from
+pub(crate) struct WebAssetConfigDropGuard;
+
+impl WebAssetConfigDropGuard {
+    pub fn new() -> Self {
+        // Set up the collect asset config
+        manganis_cli_support::Config::default()
+            .with_assets_serve_location("/")
+            .save();
+        Self {}
+    }
+}
+
+impl Drop for WebAssetConfigDropGuard {
+    fn drop(&mut self) {
+        // Reset the config
+        manganis_cli_support::Config::default().save();
+    }
+}

+ 20 - 75
packages/cli/src/builder.rs

@@ -1,16 +1,18 @@
 use crate::{
-    config::{CrateConfig, ExecutableType},
+    assets::{asset_manifest, create_assets_head, process_assets, WebAssetConfigDropGuard},
     error::{Error, Result},
     tools::Tool,
 };
 use cargo_metadata::{diagnostic::Diagnostic, Message};
+use dioxus_cli_config::crate_root;
+use dioxus_cli_config::CrateConfig;
+use dioxus_cli_config::ExecutableType;
 use indicatif::{ProgressBar, ProgressStyle};
 use lazy_static::lazy_static;
-use manganis_cli_support::AssetManifestExt;
 use serde::Serialize;
 use std::{
     fs::{copy, create_dir_all, File},
-    io::{Read, Write},
+    io::Read,
     panic,
     path::PathBuf,
     time::Duration,
@@ -51,6 +53,7 @@ pub fn build(config: &CrateConfig, _: bool, skip_assets: bool) -> Result<BuildRe
     let ignore_files = build_assets(config)?;
 
     let t_start = std::time::Instant::now();
+    let _guard = dioxus_cli_config::__private::save_config(config);
 
     // [1] Build the .wasm module
     log::info!("🚅 Running build command...");
@@ -152,7 +155,7 @@ pub fn build(config: &CrateConfig, _: bool, skip_assets: bool) -> Result<BuildRe
     }
 
     // check binaryen:wasm-opt tool
-    let dioxus_tools = dioxus_config.application.tools.clone().unwrap_or_default();
+    let dioxus_tools = dioxus_config.application.tools.clone();
     if dioxus_tools.contains_key("binaryen") {
         let info = dioxus_tools.get("binaryen").unwrap();
         let binaryen = crate::tools::Tool::Binaryen;
@@ -277,6 +280,7 @@ pub fn build_desktop(
 
     let t_start = std::time::Instant::now();
     let ignore_files = build_assets(config)?;
+    let _guard = dioxus_cli_config::__private::save_config(config);
 
     let mut cmd = subprocess::Exec::cmd("cargo")
         .env("CARGO_TARGET_DIR", &config.target_dir)
@@ -312,9 +316,9 @@ pub fn build_desktop(
     cmd = cmd.args(&config.cargo_args);
 
     let cmd = match &config.executable {
-        crate::ExecutableType::Binary(name) => cmd.arg("--bin").arg(name),
-        crate::ExecutableType::Lib(name) => cmd.arg("--lib").arg(name),
-        crate::ExecutableType::Example(name) => cmd.arg("--example").arg(name),
+        ExecutableType::Binary(name) => cmd.arg("--bin").arg(name),
+        ExecutableType::Lib(name) => cmd.arg("--lib").arg(name),
+        ExecutableType::Example(name) => cmd.arg("--example").arg(name),
     };
 
     let warning_messages = prettier_build(cmd)?;
@@ -326,7 +330,7 @@ pub fn build_desktop(
 
     let file_name: String;
     let mut res_path = match &config.executable {
-        crate::ExecutableType::Binary(name) | crate::ExecutableType::Lib(name) => {
+        ExecutableType::Binary(name) | ExecutableType::Lib(name) => {
             file_name = name.clone();
             config
                 .target_dir
@@ -334,7 +338,7 @@ pub fn build_desktop(
                 .join(release_type)
                 .join(name)
         }
-        crate::ExecutableType::Example(name) => {
+        ExecutableType::Example(name) => {
             file_name = name.clone();
             config
                 .target_dir
@@ -399,13 +403,7 @@ pub fn build_desktop(
 
     log::info!(
         "🚩 Build completed: [./{}]",
-        config
-            .dioxus_config
-            .application
-            .out_dir
-            .clone()
-            .unwrap_or_else(|| PathBuf::from("dist"))
-            .display()
+        config.dioxus_config.application.out_dir.clone().display()
     );
 
     println!("build desktop done");
@@ -416,13 +414,6 @@ pub fn build_desktop(
     })
 }
 
-fn create_assets_head(config: &CrateConfig) -> Result<()> {
-    let manifest = config.asset_manifest();
-    let mut file = File::create(config.out_dir.join("__assets_head.html"))?;
-    file.write_all(manifest.head().as_bytes())?;
-    Ok(())
-}
-
 fn prettier_build(cmd: subprocess::Exec) -> anyhow::Result<Vec<Diagnostic>> {
     let mut warning_messages: Vec<Diagnostic> = vec![];
 
@@ -482,7 +473,7 @@ fn prettier_build(cmd: subprocess::Exec) -> anyhow::Result<Vec<Diagnostic>> {
 pub fn gen_page(config: &CrateConfig, serve: bool, skip_assets: bool) -> String {
     let _gaurd = WebAssetConfigDropGuard::new();
 
-    let crate_root = crate::cargo::crate_root().unwrap();
+    let crate_root = crate_root().unwrap();
     let custom_html_file = crate_root.join("index.html");
     let mut html = if custom_html_file.is_file() {
         let mut buf = String::new();
@@ -502,8 +493,8 @@ pub fn gen_page(config: &CrateConfig, serve: bool, skip_assets: bool) -> String
     let mut script_list = resources.script.unwrap_or_default();
 
     if serve {
-        let mut dev_style = resources.dev.style.clone().unwrap_or_default();
-        let mut dev_script = resources.dev.script.unwrap_or_default();
+        let mut dev_style = resources.dev.style.clone();
+        let mut dev_script = resources.dev.script.clone();
         style_list.append(&mut dev_style);
         script_list.append(&mut dev_script);
     }
@@ -520,13 +511,12 @@ pub fn gen_page(config: &CrateConfig, serve: bool, skip_assets: bool) -> String
         .application
         .tools
         .clone()
-        .unwrap_or_default()
         .contains_key("tailwindcss")
     {
         style_str.push_str("<link rel=\"stylesheet\" href=\"/{base_path}/tailwind.css\">\n");
     }
     if !skip_assets {
-        let manifest = config.asset_manifest();
+        let manifest = asset_manifest(config);
         style_str.push_str(&manifest.head());
     }
 
@@ -577,13 +567,7 @@ pub fn gen_page(config: &CrateConfig, serve: bool, skip_assets: bool) -> String
         );
     }
 
-    let title = config
-        .dioxus_config
-        .web
-        .app
-        .title
-        .clone()
-        .unwrap_or_else(|| "dioxus | ⛺".into());
+    let title = config.dioxus_config.web.app.title.clone();
 
     replace_or_insert_before("{app_title}", &title, "</title", &mut html);
 
@@ -610,7 +594,7 @@ fn build_assets(config: &CrateConfig) -> Result<Vec<PathBuf>> {
     let mut result = vec![];
 
     let dioxus_config = &config.dioxus_config;
-    let dioxus_tools = dioxus_config.application.tools.clone().unwrap_or_default();
+    let dioxus_tools = dioxus_config.application.tools.clone();
 
     // check sass tool state
     let sass = Tool::Sass;
@@ -748,42 +732,3 @@ fn build_assets(config: &CrateConfig) -> Result<Vec<PathBuf>> {
 
     Ok(result)
 }
-
-/// Process any assets collected from the binary
-fn process_assets(config: &CrateConfig) -> anyhow::Result<()> {
-    let manifest = config.asset_manifest();
-
-    let static_asset_output_dir = PathBuf::from(
-        config
-            .dioxus_config
-            .web
-            .app
-            .base_path
-            .clone()
-            .unwrap_or_default(),
-    );
-    let static_asset_output_dir = config.out_dir.join(static_asset_output_dir);
-
-    manifest.copy_static_assets_to(static_asset_output_dir)?;
-
-    Ok(())
-}
-
-pub(crate) struct WebAssetConfigDropGuard;
-
-impl WebAssetConfigDropGuard {
-    pub fn new() -> Self {
-        // Set up the collect asset config
-        manganis_cli_support::Config::default()
-            .with_assets_serve_location("/")
-            .save();
-        Self {}
-    }
-}
-
-impl Drop for WebAssetConfigDropGuard {
-    fn drop(&mut self) {
-        // Reset the config
-        manganis_cli_support::Config::default().save();
-    }
-}

+ 1 - 1
packages/cli/src/cli/autoformat.rs

@@ -139,7 +139,7 @@ async fn format_file(
 ///
 /// Doesn't do mod-descending, so it will still try to format unreachable files. TODO.
 async fn autoformat_project(check: bool) -> Result<()> {
-    let crate_config = crate::CrateConfig::new(None)?;
+    let crate_config = dioxus_cli_config::CrateConfig::new(None)?;
 
     let files_to_format = get_project_files(&crate_config);
 

+ 4 - 10
packages/cli/src/cli/build.rs

@@ -1,8 +1,9 @@
+use crate::assets::WebAssetConfigDropGuard;
 #[cfg(feature = "plugin")]
 use crate::plugin::PluginManager;
 use crate::server::fullstack::FullstackServerEnvGuard;
 use crate::server::fullstack::FullstackWebEnvGuard;
-use crate::{cfg::Platform, WebAssetConfigDropGuard};
+use dioxus_cli_config::Platform;
 
 use super::*;
 
@@ -16,7 +17,7 @@ pub struct Build {
 
 impl Build {
     pub fn build(self, bin: Option<PathBuf>, target_dir: Option<&std::path::Path>) -> Result<()> {
-        let mut crate_config = crate::CrateConfig::new(bin)?;
+        let mut crate_config = dioxus_cli_config::CrateConfig::new(bin)?;
         if let Some(target_dir) = target_dir {
             crate_config.target_dir = target_dir.to_path_buf();
         }
@@ -96,14 +97,7 @@ impl Build {
         let mut file = std::fs::File::create(
             crate_config
                 .crate_dir
-                .join(
-                    crate_config
-                        .dioxus_config
-                        .application
-                        .out_dir
-                        .clone()
-                        .unwrap_or_else(|| PathBuf::from("dist")),
-                )
+                .join(crate_config.dioxus_config.application.out_dir.clone())
                 .join("index.html"),
         )?;
         file.write_all(temp.as_bytes())?;

+ 5 - 4
packages/cli/src/cli/bundle.rs

@@ -1,4 +1,5 @@
 use core::panic;
+use dioxus_cli_config::ExecutableType;
 use std::{fs::create_dir_all, str::FromStr};
 
 use tauri_bundler::{BundleSettings, PackageSettings, SettingsBuilder};
@@ -62,7 +63,7 @@ impl From<PackageType> for tauri_bundler::PackageType {
 
 impl Bundle {
     pub fn bundle(self, bin: Option<PathBuf>) -> Result<()> {
-        let mut crate_config = crate::CrateConfig::new(bin)?;
+        let mut crate_config = dioxus_cli_config::CrateConfig::new(bin)?;
 
         // change the release state.
         crate_config.with_release(self.build.release);
@@ -89,9 +90,9 @@ impl Bundle {
         let package = crate_config.manifest.package.unwrap();
 
         let mut name: PathBuf = match &crate_config.executable {
-            crate::ExecutableType::Binary(name)
-            | crate::ExecutableType::Lib(name)
-            | crate::ExecutableType::Example(name) => name,
+            ExecutableType::Binary(name)
+            | ExecutableType::Lib(name)
+            | ExecutableType::Example(name) => name,
         }
         .into();
         if cfg!(windows) {

+ 1 - 15
packages/cli/src/cli/cfg.rs

@@ -1,5 +1,4 @@
-use clap::ValueEnum;
-use serde::Serialize;
+use dioxus_cli_config::Platform;
 
 use super::*;
 
@@ -154,19 +153,6 @@ pub struct ConfigOptsServe {
     pub cargo_args: Vec<String>,
 }
 
-#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Serialize, Deserialize, Debug)]
-pub enum Platform {
-    #[clap(name = "web")]
-    #[serde(rename = "web")]
-    Web,
-    #[clap(name = "desktop")]
-    #[serde(rename = "desktop")]
-    Desktop,
-    #[clap(name = "fullstack")]
-    #[serde(rename = "fullstack")]
-    Fullstack,
-}
-
 /// Config options for the bundling system.
 #[derive(Clone, Debug, Default, Deserialize, Parser)]
 pub struct ConfigOptsBundle {

+ 1 - 1
packages/cli/src/cli/check.rs

@@ -47,7 +47,7 @@ async fn check_file_and_report(path: PathBuf) -> Result<()> {
 ///
 /// Doesn't do mod-descending, so it will still try to check unreachable files. TODO.
 async fn check_project_and_report() -> Result<()> {
-    let crate_config = crate::CrateConfig::new(None)?;
+    let crate_config = dioxus_cli_config::CrateConfig::new(None)?;
 
     let mut files_to_check = vec![];
     collect_rs_files(&crate_config.crate_dir, &mut files_to_check);

+ 2 - 6
packages/cli/src/cli/clean.rs

@@ -7,7 +7,7 @@ pub struct Clean {}
 
 impl Clean {
     pub fn clean(self, bin: Option<PathBuf>) -> Result<()> {
-        let crate_config = crate::CrateConfig::new(bin)?;
+        let crate_config = dioxus_cli_config::CrateConfig::new(bin)?;
 
         let output = Command::new("cargo")
             .arg("clean")
@@ -19,11 +19,7 @@ impl Clean {
             return custom_error!("Cargo clean failed.");
         }
 
-        let out_dir = crate_config
-            .dioxus_config
-            .application
-            .out_dir
-            .unwrap_or_else(|| PathBuf::from("dist"));
+        let out_dir = crate_config.dioxus_config.application.out_dir;
         if crate_config.crate_dir.join(&out_dir).is_dir() {
             remove_dir_all(crate_config.crate_dir.join(&out_dir))?;
         }

+ 7 - 2
packages/cli/src/cli/config.rs

@@ -1,3 +1,5 @@
+use dioxus_cli_config::crate_root;
+
 use super::*;
 
 /// Dioxus config file controls
@@ -26,7 +28,7 @@ pub enum Config {
 
 impl Config {
     pub fn config(self) -> Result<()> {
-        let crate_root = crate::cargo::crate_root()?;
+        let crate_root = crate_root()?;
         match self {
             Config::Init {
                 name,
@@ -48,7 +50,10 @@ impl Config {
                 log::info!("🚩 Init config file completed.");
             }
             Config::FormatPrint {} => {
-                println!("{:#?}", crate::CrateConfig::new(None)?.dioxus_config);
+                println!(
+                    "{:#?}",
+                    dioxus_cli_config::CrateConfig::new(None)?.dioxus_config
+                );
             }
             Config::CustomHtml {} => {
                 let html_path = crate_root.join("index.html");

+ 2 - 1
packages/cli/src/cli/mod.rs

@@ -15,9 +15,10 @@ use crate::{
     cfg::{ConfigOptsBuild, ConfigOptsServe},
     custom_error,
     error::Result,
-    gen_page, server, CrateConfig, Error,
+    gen_page, server, Error,
 };
 use clap::{Parser, Subcommand};
+use dioxus_cli_config::CrateConfig;
 use html_parser::Dom;
 use serde::Deserialize;
 use std::{

+ 9 - 15
packages/cli/src/cli/serve.rs

@@ -1,3 +1,5 @@
+use dioxus_cli_config::Platform;
+
 use super::*;
 use std::{fs::create_dir_all, io::Write, path::PathBuf};
 
@@ -11,7 +13,7 @@ pub struct Serve {
 
 impl Serve {
     pub async fn serve(self, bin: Option<PathBuf>) -> Result<()> {
-        let mut crate_config = crate::CrateConfig::new(bin)?;
+        let mut crate_config = dioxus_cli_config::CrateConfig::new(bin)?;
         let serve_cfg = self.serve.clone();
 
         // change the relase state.
@@ -32,9 +34,6 @@ impl Serve {
             crate_config.set_features(self.serve.features.unwrap());
         }
 
-        // Subdirectories don't work with the server
-        crate_config.dioxus_config.web.app.base_path = None;
-
         if let Some(target) = self.serve.target {
             crate_config.set_target(target);
         }
@@ -47,7 +46,7 @@ impl Serve {
             .unwrap_or(crate_config.dioxus_config.application.default_platform);
 
         match platform {
-            cfg::Platform::Web => {
+            Platform::Web => {
                 // generate dev-index page
                 Serve::regen_dev_page(&crate_config, self.serve.skip_assets)?;
 
@@ -60,10 +59,10 @@ impl Serve {
                 )
                 .await?;
             }
-            cfg::Platform::Desktop => {
+            Platform::Desktop => {
                 server::desktop::startup(crate_config.clone(), &serve_cfg).await?;
             }
-            cfg::Platform::Fullstack => {
+            Platform::Fullstack => {
                 server::fullstack::startup(crate_config.clone(), &serve_cfg).await?;
             }
         }
@@ -73,14 +72,9 @@ impl Serve {
     pub fn regen_dev_page(crate_config: &CrateConfig, skip_assets: bool) -> Result<()> {
         let serve_html = gen_page(crate_config, true, skip_assets);
 
-        let dist_path = crate_config.crate_dir.join(
-            crate_config
-                .dioxus_config
-                .application
-                .out_dir
-                .clone()
-                .unwrap_or_else(|| PathBuf::from("dist")),
-        );
+        let dist_path = crate_config
+            .crate_dir
+            .join(crate_config.dioxus_config.application.out_dir.clone());
         if !dist_path.is_dir() {
             create_dir_all(&dist_path)?;
         }

+ 0 - 608
packages/cli/src/config.rs

@@ -1,608 +0,0 @@
-use crate::{cfg::Platform, error::Result};
-use manganis_cli_support::AssetManifest;
-use manganis_cli_support::AssetManifestExt;
-use serde::{Deserialize, Serialize};
-use std::{
-    collections::HashMap,
-    path::{Path, PathBuf},
-};
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct DioxusConfig {
-    pub application: ApplicationConfig,
-
-    pub web: WebConfig,
-
-    #[serde(default)]
-    pub bundle: BundleConfig,
-
-    #[serde(default = "default_plugin")]
-    pub plugin: toml::Value,
-}
-
-fn default_plugin() -> toml::Value {
-    toml::Value::Boolean(true)
-}
-
-impl DioxusConfig {
-    pub fn load(bin: Option<PathBuf>) -> crate::error::Result<Option<DioxusConfig>> {
-        let crate_dir = crate::cargo::crate_root();
-
-        let crate_dir = match crate_dir {
-            Ok(dir) => {
-                if let Some(bin) = bin {
-                    dir.join(bin)
-                } else {
-                    dir
-                }
-            }
-            Err(_) => return Ok(None),
-        };
-        let crate_dir = crate_dir.as_path();
-
-        let Some(dioxus_conf_file) = acquire_dioxus_toml(crate_dir) else {
-            return Ok(None);
-        };
-
-        let dioxus_conf_file = dioxus_conf_file.as_path();
-        let cfg = toml::from_str::<DioxusConfig>(&std::fs::read_to_string(dioxus_conf_file)?)
-            .map_err(|err| {
-                let error_location = dioxus_conf_file
-                    .strip_prefix(crate_dir)
-                    .unwrap_or(dioxus_conf_file)
-                    .display();
-                crate::Error::Unique(format!("{error_location} {err}"))
-            })
-            .map(Some);
-        match cfg {
-            Ok(Some(mut cfg)) => {
-                let name = cfg.application.name.clone();
-                if cfg.bundle.identifier.is_none() {
-                    cfg.bundle.identifier = Some(format!("io.github.{name}"));
-                }
-                if cfg.bundle.publisher.is_none() {
-                    cfg.bundle.publisher = Some(name);
-                }
-                Ok(Some(cfg))
-            }
-            cfg => cfg,
-        }
-    }
-}
-
-fn acquire_dioxus_toml(dir: &Path) -> Option<PathBuf> {
-    // prefer uppercase
-    let uppercase_conf = dir.join("Dioxus.toml");
-    if uppercase_conf.is_file() {
-        return Some(uppercase_conf);
-    }
-
-    // lowercase is fine too
-    let lowercase_conf = dir.join("dioxus.toml");
-    if lowercase_conf.is_file() {
-        return Some(lowercase_conf);
-    }
-
-    None
-}
-
-impl Default for DioxusConfig {
-    fn default() -> Self {
-        let name = "name";
-        Self {
-            application: ApplicationConfig {
-                name: name.into(),
-                default_platform: Platform::Web,
-                out_dir: Some(PathBuf::from("dist")),
-                asset_dir: Some(PathBuf::from("public")),
-
-                tools: None,
-
-                sub_package: None,
-            },
-            web: WebConfig {
-                app: WebAppConfig {
-                    title: Some("dioxus | ⛺".into()),
-                    base_path: None,
-                },
-                proxy: Some(vec![]),
-                watcher: WebWatcherConfig {
-                    watch_path: Some(vec![PathBuf::from("src"), PathBuf::from("examples")]),
-                    reload_html: Some(false),
-                    index_on_404: Some(true),
-                },
-                resource: WebResourceConfig {
-                    dev: WebDevResourceConfig {
-                        style: Some(vec![]),
-                        script: Some(vec![]),
-                    },
-                    style: Some(vec![]),
-                    script: Some(vec![]),
-                },
-                https: WebHttpsConfig {
-                    enabled: None,
-                    mkcert: None,
-                    key_path: None,
-                    cert_path: None,
-                },
-            },
-            bundle: BundleConfig {
-                identifier: Some(format!("io.github.{name}")),
-                publisher: Some(name.into()),
-                ..Default::default()
-            },
-            plugin: toml::Value::Table(toml::map::Map::new()),
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct ApplicationConfig {
-    pub name: String,
-    pub default_platform: Platform,
-    pub out_dir: Option<PathBuf>,
-    pub asset_dir: Option<PathBuf>,
-
-    pub tools: Option<HashMap<String, toml::Value>>,
-
-    pub sub_package: Option<String>,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct WebConfig {
-    pub app: WebAppConfig,
-    pub proxy: Option<Vec<WebProxyConfig>>,
-    pub watcher: WebWatcherConfig,
-    pub resource: WebResourceConfig,
-    #[serde(default)]
-    pub https: WebHttpsConfig,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct WebAppConfig {
-    pub title: Option<String>,
-    pub base_path: Option<String>,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct WebProxyConfig {
-    pub backend: String,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct WebWatcherConfig {
-    pub watch_path: Option<Vec<PathBuf>>,
-    pub reload_html: Option<bool>,
-    pub index_on_404: Option<bool>,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct WebResourceConfig {
-    pub dev: WebDevResourceConfig,
-    pub style: Option<Vec<PathBuf>>,
-    pub script: Option<Vec<PathBuf>>,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct WebDevResourceConfig {
-    pub style: Option<Vec<PathBuf>>,
-    pub script: Option<Vec<PathBuf>>,
-}
-
-#[derive(Debug, Default, Clone, Serialize, Deserialize)]
-pub struct WebHttpsConfig {
-    pub enabled: Option<bool>,
-    pub mkcert: Option<bool>,
-    pub key_path: Option<String>,
-    pub cert_path: Option<String>,
-}
-
-#[derive(Debug, Clone)]
-pub struct CrateConfig {
-    pub out_dir: PathBuf,
-    pub crate_dir: PathBuf,
-    pub workspace_dir: PathBuf,
-    pub target_dir: PathBuf,
-    pub asset_dir: PathBuf,
-    pub manifest: cargo_toml::Manifest<cargo_toml::Value>,
-    pub executable: ExecutableType,
-    pub dioxus_config: DioxusConfig,
-    pub release: bool,
-    pub hot_reload: bool,
-    pub cross_origin_policy: bool,
-    pub verbose: bool,
-    pub custom_profile: Option<String>,
-    pub features: Option<Vec<String>>,
-    pub target: Option<String>,
-    pub cargo_args: Vec<String>,
-}
-
-#[derive(Debug, Clone)]
-pub enum ExecutableType {
-    Binary(String),
-    Lib(String),
-    Example(String),
-}
-
-impl CrateConfig {
-    pub fn new(bin: Option<PathBuf>) -> Result<Self> {
-        let dioxus_config = DioxusConfig::load(bin.clone())?.unwrap_or_default();
-
-        let crate_root = crate::cargo::crate_root()?;
-
-        let crate_dir = if let Some(package) = &dioxus_config.application.sub_package {
-            crate_root.join(package)
-        } else if let Some(bin) = bin {
-            crate_root.join(bin)
-        } else {
-            crate_root
-        };
-
-        let meta = crate::cargo::Metadata::get()?;
-        let workspace_dir = meta.workspace_root;
-        let target_dir = meta.target_directory;
-
-        let out_dir = match dioxus_config.application.out_dir {
-            Some(ref v) => crate_dir.join(v),
-            None => crate_dir.join("dist"),
-        };
-
-        let cargo_def = &crate_dir.join("Cargo.toml");
-
-        let asset_dir = match dioxus_config.application.asset_dir {
-            Some(ref v) => crate_dir.join(v),
-            None => crate_dir.join("public"),
-        };
-
-        let manifest = cargo_toml::Manifest::from_path(cargo_def).unwrap();
-
-        let mut output_filename = String::from("dioxus_app");
-        if let Some(package) = &manifest.package.as_ref() {
-            output_filename = match &package.default_run {
-                Some(default_run_target) => default_run_target.to_owned(),
-                None => manifest
-                    .bin
-                    .iter()
-                    .find(|b| b.name == manifest.package.as_ref().map(|pkg| pkg.name.clone()))
-                    .or(manifest
-                        .bin
-                        .iter()
-                        .find(|b| b.path == Some("src/main.rs".to_owned())))
-                    .or(manifest.bin.first())
-                    .or(manifest.lib.as_ref())
-                    .and_then(|prod| prod.name.clone())
-                    .unwrap_or(String::from("dioxus_app")),
-            };
-        }
-
-        let executable = ExecutableType::Binary(output_filename);
-
-        let release = false;
-        let hot_reload = false;
-        let verbose = false;
-        let custom_profile = None;
-        let features = None;
-        let target = None;
-        let cargo_args = vec![];
-
-        Ok(Self {
-            out_dir,
-            crate_dir,
-            workspace_dir,
-            target_dir,
-            asset_dir,
-            manifest,
-            executable,
-            release,
-            dioxus_config,
-            hot_reload,
-            cross_origin_policy: false,
-            custom_profile,
-            features,
-            verbose,
-            target,
-            cargo_args,
-        })
-    }
-
-    pub fn asset_manifest(&self) -> AssetManifest {
-        AssetManifest::load_from_path(
-            self.crate_dir.join("Cargo.toml"),
-            self.workspace_dir.join("Cargo.lock"),
-        )
-    }
-
-    pub fn as_example(&mut self, example_name: String) -> &mut Self {
-        self.executable = ExecutableType::Example(example_name);
-        self
-    }
-
-    pub fn with_release(&mut self, release: bool) -> &mut Self {
-        self.release = release;
-        self
-    }
-
-    pub fn with_hot_reload(&mut self, hot_reload: bool) -> &mut Self {
-        self.hot_reload = hot_reload;
-        self
-    }
-
-    pub fn with_cross_origin_policy(&mut self, cross_origin_policy: bool) -> &mut Self {
-        self.cross_origin_policy = cross_origin_policy;
-        self
-    }
-
-    pub fn with_verbose(&mut self, verbose: bool) -> &mut Self {
-        self.verbose = verbose;
-        self
-    }
-
-    pub fn set_profile(&mut self, profile: String) -> &mut Self {
-        self.custom_profile = Some(profile);
-        self
-    }
-
-    pub fn set_features(&mut self, features: Vec<String>) -> &mut Self {
-        self.features = Some(features);
-        self
-    }
-
-    pub fn set_target(&mut self, target: String) -> &mut Self {
-        self.target = Some(target);
-        self
-    }
-
-    pub fn set_cargo_args(&mut self, cargo_args: Vec<String>) -> &mut Self {
-        self.cargo_args = cargo_args;
-        self
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, Default)]
-pub struct BundleConfig {
-    pub identifier: Option<String>,
-    pub publisher: Option<String>,
-    pub icon: Option<Vec<String>>,
-    pub resources: Option<Vec<String>>,
-    pub copyright: Option<String>,
-    pub category: Option<String>,
-    pub short_description: Option<String>,
-    pub long_description: Option<String>,
-    pub external_bin: Option<Vec<String>>,
-    pub deb: Option<DebianSettings>,
-    pub macos: Option<MacOsSettings>,
-    pub windows: Option<WindowsSettings>,
-}
-
-impl From<BundleConfig> for tauri_bundler::BundleSettings {
-    fn from(val: BundleConfig) -> Self {
-        tauri_bundler::BundleSettings {
-            identifier: val.identifier,
-            publisher: val.publisher,
-            icon: val.icon,
-            resources: val.resources,
-            copyright: val.copyright,
-            category: val.category.and_then(|c| c.parse().ok()),
-            short_description: val.short_description,
-            long_description: val.long_description,
-            external_bin: val.external_bin,
-            deb: val.deb.map(Into::into).unwrap_or_default(),
-            macos: val.macos.map(Into::into).unwrap_or_default(),
-            windows: val.windows.map(Into::into).unwrap_or_default(),
-            ..Default::default()
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, Default)]
-pub struct DebianSettings {
-    pub depends: Option<Vec<String>>,
-    pub files: HashMap<PathBuf, PathBuf>,
-    pub nsis: Option<NsisSettings>,
-}
-
-impl From<DebianSettings> for tauri_bundler::DebianSettings {
-    fn from(val: DebianSettings) -> Self {
-        tauri_bundler::DebianSettings {
-            depends: val.depends,
-            files: val.files,
-            desktop_template: None,
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, Default)]
-pub struct WixSettings {
-    pub language: Vec<(String, Option<PathBuf>)>,
-    pub template: Option<PathBuf>,
-    pub fragment_paths: Vec<PathBuf>,
-    pub component_group_refs: Vec<String>,
-    pub component_refs: Vec<String>,
-    pub feature_group_refs: Vec<String>,
-    pub feature_refs: Vec<String>,
-    pub merge_refs: Vec<String>,
-    pub skip_webview_install: bool,
-    pub license: Option<PathBuf>,
-    pub enable_elevated_update_task: bool,
-    pub banner_path: Option<PathBuf>,
-    pub dialog_image_path: Option<PathBuf>,
-    pub fips_compliant: bool,
-}
-
-impl From<WixSettings> for tauri_bundler::WixSettings {
-    fn from(val: WixSettings) -> Self {
-        tauri_bundler::WixSettings {
-            language: tauri_bundler::bundle::WixLanguage({
-                let mut languages: Vec<_> = val
-                    .language
-                    .iter()
-                    .map(|l| {
-                        (
-                            l.0.clone(),
-                            tauri_bundler::bundle::WixLanguageConfig {
-                                locale_path: l.1.clone(),
-                            },
-                        )
-                    })
-                    .collect();
-                if languages.is_empty() {
-                    languages.push(("en-US".into(), Default::default()));
-                }
-                languages
-            }),
-            template: val.template,
-            fragment_paths: val.fragment_paths,
-            component_group_refs: val.component_group_refs,
-            component_refs: val.component_refs,
-            feature_group_refs: val.feature_group_refs,
-            feature_refs: val.feature_refs,
-            merge_refs: val.merge_refs,
-            skip_webview_install: val.skip_webview_install,
-            license: val.license,
-            enable_elevated_update_task: val.enable_elevated_update_task,
-            banner_path: val.banner_path,
-            dialog_image_path: val.dialog_image_path,
-            fips_compliant: val.fips_compliant,
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, Default)]
-pub struct MacOsSettings {
-    pub frameworks: Option<Vec<String>>,
-    pub minimum_system_version: Option<String>,
-    pub license: Option<String>,
-    pub exception_domain: Option<String>,
-    pub signing_identity: Option<String>,
-    pub provider_short_name: Option<String>,
-    pub entitlements: Option<String>,
-    pub info_plist_path: Option<PathBuf>,
-}
-
-impl From<MacOsSettings> for tauri_bundler::MacOsSettings {
-    fn from(val: MacOsSettings) -> Self {
-        tauri_bundler::MacOsSettings {
-            frameworks: val.frameworks,
-            minimum_system_version: val.minimum_system_version,
-            license: val.license,
-            exception_domain: val.exception_domain,
-            signing_identity: val.signing_identity,
-            provider_short_name: val.provider_short_name,
-            entitlements: val.entitlements,
-            info_plist_path: val.info_plist_path,
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct WindowsSettings {
-    pub digest_algorithm: Option<String>,
-    pub certificate_thumbprint: Option<String>,
-    pub timestamp_url: Option<String>,
-    pub tsp: bool,
-    pub wix: Option<WixSettings>,
-    pub icon_path: Option<PathBuf>,
-    pub webview_install_mode: WebviewInstallMode,
-    pub webview_fixed_runtime_path: Option<PathBuf>,
-    pub allow_downgrades: bool,
-    pub nsis: Option<NsisSettings>,
-}
-
-impl From<WindowsSettings> for tauri_bundler::WindowsSettings {
-    fn from(val: WindowsSettings) -> Self {
-        tauri_bundler::WindowsSettings {
-            digest_algorithm: val.digest_algorithm,
-            certificate_thumbprint: val.certificate_thumbprint,
-            timestamp_url: val.timestamp_url,
-            tsp: val.tsp,
-            wix: val.wix.map(Into::into),
-            icon_path: val.icon_path.unwrap_or("icons/icon.ico".into()),
-            webview_install_mode: val.webview_install_mode.into(),
-            webview_fixed_runtime_path: val.webview_fixed_runtime_path,
-            allow_downgrades: val.allow_downgrades,
-            nsis: val.nsis.map(Into::into),
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct NsisSettings {
-    pub template: Option<PathBuf>,
-    pub license: Option<PathBuf>,
-    pub header_image: Option<PathBuf>,
-    pub sidebar_image: Option<PathBuf>,
-    pub installer_icon: Option<PathBuf>,
-    pub install_mode: NSISInstallerMode,
-    pub languages: Option<Vec<String>>,
-    pub custom_language_files: Option<HashMap<String, PathBuf>>,
-    pub display_language_selector: bool,
-}
-
-impl From<NsisSettings> for tauri_bundler::NsisSettings {
-    fn from(val: NsisSettings) -> Self {
-        tauri_bundler::NsisSettings {
-            license: val.license,
-            header_image: val.header_image,
-            sidebar_image: val.sidebar_image,
-            installer_icon: val.installer_icon,
-            install_mode: val.install_mode.into(),
-            languages: val.languages,
-            display_language_selector: val.display_language_selector,
-            custom_language_files: None,
-            template: None,
-            compression: None,
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub enum NSISInstallerMode {
-    CurrentUser,
-    PerMachine,
-    Both,
-}
-
-impl From<NSISInstallerMode> for tauri_utils::config::NSISInstallerMode {
-    fn from(val: NSISInstallerMode) -> Self {
-        match val {
-            NSISInstallerMode::CurrentUser => tauri_utils::config::NSISInstallerMode::CurrentUser,
-            NSISInstallerMode::PerMachine => tauri_utils::config::NSISInstallerMode::PerMachine,
-            NSISInstallerMode::Both => tauri_utils::config::NSISInstallerMode::Both,
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub enum WebviewInstallMode {
-    Skip,
-    DownloadBootstrapper { silent: bool },
-    EmbedBootstrapper { silent: bool },
-    OfflineInstaller { silent: bool },
-    FixedRuntime { path: PathBuf },
-}
-
-impl WebviewInstallMode {
-    fn into(self) -> tauri_utils::config::WebviewInstallMode {
-        match self {
-            Self::Skip => tauri_utils::config::WebviewInstallMode::Skip,
-            Self::DownloadBootstrapper { silent } => {
-                tauri_utils::config::WebviewInstallMode::DownloadBootstrapper { silent }
-            }
-            Self::EmbedBootstrapper { silent } => {
-                tauri_utils::config::WebviewInstallMode::EmbedBootstrapper { silent }
-            }
-            Self::OfflineInstaller { silent } => {
-                tauri_utils::config::WebviewInstallMode::OfflineInstaller { silent }
-            }
-            Self::FixedRuntime { path } => {
-                tauri_utils::config::WebviewInstallMode::FixedRuntime { path }
-            }
-        }
-    }
-}
-
-impl Default for WebviewInstallMode {
-    fn default() -> Self {
-        Self::OfflineInstaller { silent: false }
-    }
-}

+ 18 - 0
packages/cli/src/error.rs

@@ -72,6 +72,24 @@ impl From<hyper::Error> for Error {
     }
 }
 
+impl From<dioxus_cli_config::LoadDioxusConfigError> for Error {
+    fn from(e: dioxus_cli_config::LoadDioxusConfigError) -> Self {
+        Self::RuntimeError(e.to_string())
+    }
+}
+
+impl From<dioxus_cli_config::CargoError> for Error {
+    fn from(e: dioxus_cli_config::CargoError) -> Self {
+        Self::CargoError(e.to_string())
+    }
+}
+
+impl From<dioxus_cli_config::CrateConfigError> for Error {
+    fn from(e: dioxus_cli_config::CrateConfigError) -> Self {
+        Self::RuntimeError(e.to_string())
+    }
+}
+
 #[macro_export]
 macro_rules! custom_error {
     ($msg:literal $(,)?) => {

+ 1 - 6
packages/cli/src/lib.rs

@@ -4,21 +4,16 @@
 
 pub const DIOXUS_CLI_VERSION: &str = "0.4.1";
 
+mod assets;
 pub mod builder;
 pub mod server;
 pub mod tools;
 
 pub use builder::*;
 
-pub mod cargo;
-pub use cargo::*;
-
 pub mod cli;
 pub use cli::*;
 
-pub mod config;
-pub use config::*;
-
 pub mod error;
 pub use error::*;
 

+ 1 - 0
packages/cli/src/main.rs

@@ -1,3 +1,4 @@
+use dioxus_cli_config::DioxusConfig;
 use std::path::PathBuf;
 
 use anyhow::anyhow;

+ 7 - 4
packages/cli/src/server/desktop/mod.rs

@@ -5,8 +5,11 @@ use crate::{
         output::{print_console_info, PrettierOptions},
         setup_file_watcher,
     },
-    BuildResult, CrateConfig, Result,
+    BuildResult, Result,
 };
+use dioxus_cli_config::CrateConfig;
+use dioxus_cli_config::ExecutableType;
+
 use dioxus_hot_reload::HotReloadMsg;
 use dioxus_html::HtmlCtx;
 use dioxus_rsx::hot_reload::*;
@@ -215,9 +218,9 @@ fn start_desktop(config: &CrateConfig, skip_assets: bool) -> Result<(RAIIChild,
     let result = crate::builder::build_desktop(config, true, skip_assets)?;
 
     match &config.executable {
-        crate::ExecutableType::Binary(name)
-        | crate::ExecutableType::Lib(name)
-        | crate::ExecutableType::Example(name) => {
+        ExecutableType::Binary(name)
+        | ExecutableType::Lib(name)
+        | ExecutableType::Example(name) => {
             let mut file = config.out_dir.join(name);
             if cfg!(windows) {
                 file.set_extension("exe");

+ 5 - 2
packages/cli/src/server/fullstack/mod.rs

@@ -1,6 +1,9 @@
+use dioxus_cli_config::CrateConfig;
+
 use crate::{
+    assets::WebAssetConfigDropGuard,
     cfg::{ConfigOptsBuild, ConfigOptsServe},
-    CrateConfig, Result, WebAssetConfigDropGuard,
+    Result,
 };
 
 use super::{desktop, Platform};
@@ -86,7 +89,7 @@ fn build_web(serve: ConfigOptsServe, target_directory: &std::path::Path) -> Resu
         }
         None => web_config.features = Some(vec![web_feature]),
     };
-    web_config.platform = Some(crate::cfg::Platform::Web);
+    web_config.platform = Some(dioxus_cli_config::Platform::Web);
 
     let _gaurd = FullstackWebEnvGuard::new(&web_config);
     crate::cli::build::Build { build: web_config }.build(None, Some(target_directory))

+ 4 - 12
packages/cli/src/server/mod.rs

@@ -1,14 +1,12 @@
-use crate::{cfg::ConfigOptsServe, BuildResult, CrateConfig, Result};
+use crate::{cfg::ConfigOptsServe, BuildResult, Result};
+use dioxus_cli_config::CrateConfig;
 
 use cargo_metadata::diagnostic::Diagnostic;
 use dioxus_core::Template;
 use dioxus_html::HtmlCtx;
 use dioxus_rsx::hot_reload::*;
 use notify::{RecommendedWatcher, Watcher};
-use std::{
-    path::PathBuf,
-    sync::{Arc, Mutex},
-};
+use std::sync::{Arc, Mutex};
 use tokio::sync::broadcast::{self};
 
 mod output;
@@ -27,13 +25,7 @@ async fn setup_file_watcher<F: Fn() -> Result<BuildResult> + Send + 'static>(
     let mut last_update_time = chrono::Local::now().timestamp();
 
     // file watcher: check file change
-    let allow_watch_path = config
-        .dioxus_config
-        .web
-        .watcher
-        .watch_path
-        .clone()
-        .unwrap_or_else(|| vec![PathBuf::from("src"), PathBuf::from("examples")]);
+    let allow_watch_path = config.dioxus_config.web.watcher.watch_path.clone();
 
     let watcher_config = config.clone();
     let mut watcher = notify::recommended_watcher(move |info: notify::Result<notify::Event>| {

+ 9 - 16
packages/cli/src/server/output.rs

@@ -1,6 +1,7 @@
 use crate::server::Diagnostic;
-use crate::CrateConfig;
 use colored::Colorize;
+use dioxus_cli_config::crate_root;
+use dioxus_cli_config::CrateConfig;
 use std::path::PathBuf;
 use std::process::Command;
 
@@ -43,25 +44,19 @@ pub fn print_console_info(
         profile = config.custom_profile.as_ref().unwrap().to_string();
     }
     let hot_reload = if config.hot_reload { "RSX" } else { "Normal" };
-    let crate_root = crate::cargo::crate_root().unwrap();
+    let crate_root = crate_root().unwrap();
     let custom_html_file = if crate_root.join("index.html").is_file() {
         "Custom [index.html]"
     } else {
         "Default"
     };
-    let url_rewrite = if config
-        .dioxus_config
-        .web
-        .watcher
-        .index_on_404
-        .unwrap_or(false)
-    {
+    let url_rewrite = if config.dioxus_config.web.watcher.index_on_404 {
         "True"
     } else {
         "False"
     };
 
-    let proxies = config.dioxus_config.web.proxy.as_ref();
+    let proxies = &config.dioxus_config.web.proxy;
 
     if options.changed.is_empty() {
         println!(
@@ -109,12 +104,10 @@ pub fn print_console_info(
     println!();
     println!("\t> Profile : {}", profile.green());
     println!("\t> Hot Reload : {}", hot_reload.cyan());
-    if let Some(proxies) = proxies {
-        if !proxies.is_empty() {
-            println!("\t> Proxies :");
-            for proxy in proxies {
-                println!("\t\t- {}", proxy.backend.blue());
-            }
+    if !proxies.is_empty() {
+        println!("\t> Proxies :");
+        for proxy in proxies {
+            println!("\t\t- {}", proxy.backend.blue());
         }
     }
     println!("\t> Index Template : {}", custom_html_file.green());

+ 18 - 15
packages/cli/src/server/web/mod.rs

@@ -5,7 +5,7 @@ use crate::{
         output::{print_console_info, PrettierOptions, WebServerInfo},
         setup_file_watcher, HotReloadState,
     },
-    BuildResult, CrateConfig, Result, WebHttpsConfig,
+    BuildResult, Result,
 };
 use axum::{
     body::{Full, HttpBody},
@@ -20,6 +20,8 @@ use axum::{
     Router,
 };
 use axum_server::tls_rustls::RustlsConfig;
+use dioxus_cli_config::CrateConfig;
+use dioxus_cli_config::WebHttpsConfig;
 
 use dioxus_html::HtmlCtx;
 use dioxus_rsx::hot_reload::*;
@@ -277,12 +279,7 @@ async fn setup_router(
         .override_response_header(HeaderName::from_static("cross-origin-opener-policy"), coop)
         .and_then(
             move |response: Response<ServeFileSystemResponseBody>| async move {
-                let mut response = if file_service_config
-                    .dioxus_config
-                    .web
-                    .watcher
-                    .index_on_404
-                    .unwrap_or(false)
+                let mut response = if file_service_config.dioxus_config.web.watcher.index_on_404
                     && response.status() == StatusCode::NOT_FOUND
                 {
                     let body = Full::from(
@@ -321,7 +318,7 @@ async fn setup_router(
     let mut router = Router::new().route("/_dioxus/ws", get(ws_handler));
 
     // Setup proxy
-    for proxy_config in config.dioxus_config.web.proxy.unwrap_or_default() {
+    for proxy_config in config.dioxus_config.web.proxy {
         router = proxy::add_proxy(router, &proxy_config)?;
     }
 
@@ -335,6 +332,18 @@ async fn setup_router(
         },
     ));
 
+    router = if let Some(base_path) = config.dioxus_config.web.app.base_path.clone() {
+        let base_path = format!("/{}", base_path.trim_matches('/'));
+        Router::new()
+            .nest(&base_path, axum::routing::any_service(router))
+            .fallback(get(move || {
+                let base_path = base_path.clone();
+                async move { format!("Outside of the base path: {}", base_path) }
+            }))
+    } else {
+        router
+    };
+
     // Setup routes
     router = router
         .route("/_dioxus/hot_reload", get(hot_reload_handler))
@@ -438,13 +447,7 @@ fn build(config: &CrateConfig, reload_tx: &Sender<()>, skip_assets: bool) -> Res
     let result = builder::build(config, true, skip_assets)?;
     // change the websocket reload state to true;
     // the page will auto-reload.
-    if config
-        .dioxus_config
-        .web
-        .watcher
-        .reload_html
-        .unwrap_or(false)
-    {
+    if config.dioxus_config.web.watcher.reload_html {
         let _ = Serve::regen_dev_page(config, skip_assets);
     }
     let _ = reload_tx.send(());

+ 2 - 1
packages/cli/src/server/web/proxy.rs

@@ -1,4 +1,5 @@
-use crate::{Result, WebProxyConfig};
+use crate::Result;
+use dioxus_cli_config::WebProxyConfig;
 
 use anyhow::Context;
 use axum::{http::StatusCode, routing::any, Router};

+ 1 - 0
packages/desktop/Cargo.toml

@@ -19,6 +19,7 @@ dioxus-html = { workspace = true, features = [
 ] }
 dioxus-interpreter-js = { workspace = true, features = ["binary-protocol"] }
 dioxus-hot-reload = { workspace = true, optional = true }
+dioxus-cli-config = { workspace = true }
 
 serde = "1.0.136"
 serde_json = "1.0.79"

+ 2 - 2
packages/desktop/src/app.rs

@@ -87,7 +87,7 @@ impl<P: 'static> App<P> {
         crate::collect_assets::copy_assets();
 
         // Set the event converter
-        dioxus_html::set_event_converter(Box::new(SerializedHtmlEventConverter));
+        dioxus_html::set_event_converter(Box::new(crate::events::SerializedHtmlEventConverter));
 
         // Allow hotreloading to work - but only in debug mode
         #[cfg(all(feature = "hot-reload", debug_assertions))]
@@ -248,7 +248,7 @@ impl<P: 'static> App<P> {
         let as_any = match data {
             dioxus_html::EventData::Mounted => {
                 let element = DesktopElement::new(element, view.desktop_context.clone(), query);
-                Rc::new(PlatformEventData::new(Box::new(MountedData::new(element))))
+                Rc::new(PlatformEventData::new(Box::new(element)))
             }
             _ => data.into_any(),
         };

+ 6 - 1
packages/desktop/src/config.rs

@@ -47,7 +47,12 @@ impl Config {
     /// Initializes a new `WindowBuilder` with default values.
     #[inline]
     pub fn new() -> Self {
-        let window = WindowBuilder::new().with_title("Dioxus app");
+        let window = WindowBuilder::new().with_title(
+            dioxus_cli_config::CURRENT_CONFIG
+                .as_ref()
+                .map(|c| c.dioxus_config.application.name.clone())
+                .unwrap_or("Dioxus App".to_string()),
+        );
 
         Self {
             // event_handler: None,

+ 15 - 21
packages/fullstack/Cargo.toml

@@ -16,18 +16,14 @@ dioxus_server_macro = { workspace = true }
 
 # warp
 warp = { version = "0.3.5", features = ["compression-gzip"], optional = true }
-http-body = { version = "0.4.5", optional = true }
-http-body-util = "0.1.0-rc.2"
 
 # axum
-axum = { version = "0.6.1", features = ["ws", "macros"], optional = true }
+axum = { version = "0.6.1", features = ["ws", "macros"], default-features = false, optional = true }
 tower-http = { version = "0.4.0", optional = true, features = ["fs", "compression-gzip"] }
-tower = { version = "0.4.13", features = ["util"], optional = true }
-axum-macros = "0.3.7"
 
 # salvo
 salvo = { version = "0.63.0", optional = true, features = ["serve-static", "websocket", "compression"] }
-serde = "1.0.159"
+http-body-util = { version = "0.1.0-rc.2", optional = true }
 
 # Dioxus + SSR
 dioxus = { workspace = true }
@@ -45,24 +41,25 @@ dioxus-desktop = { workspace = true, optional = true }
 dioxus-router = { workspace = true, optional = true }
 
 tracing = { workspace = true }
-tracing-futures = { workspace = true }
+tracing-futures = { workspace = true, optional = true }
 once_cell = "1.17.1"
-thiserror = { workspace = true }
-tokio = { workspace = true, features = ["full"], optional = true }
+tokio = { workspace = true, features = ["rt", "sync", "rt-multi-thread"], optional = true }
 tokio-util = { version = "0.7.8", features = ["rt"], optional = true }
-object-pool = "0.5.4"
-anymap = "0.12.1"
+anymap = { version = "0.12.1", optional = true }
 
+serde = "1.0.159"
 serde_json = { version = "1.0.95", optional = true }
 tokio-stream = { version = "0.1.12", features = ["sync"], optional = true }
-futures-util = { workspace = true, optional = true }
-postcard = { version = "1.0.4", features = ["use-std"] }
+futures-util = { workspace = true, default-features = false, optional = true }
+ciborium = "0.2.1"
 base64 = "0.21.0"
 
-pin-project = "1.1.2"
+pin-project = { version = "1.1.2", optional = true }
+thiserror = { workspace = true, optional = true }
 async-trait = "0.1.71"
 bytes = "1.4.0"
-tower-layer = "0.3.2"
+tower = { version = "0.4.13", features = ["util"], optional = true }
+tower-layer = { version = "0.3.2", optional = true }
 
 [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
 dioxus-hot-reload = { workspace = true }
@@ -75,17 +72,14 @@ web-sys = { version = "0.3.61", features = ["Window", "Document", "Element", "Ht
 manganis-cli-support = { git = "https://github.com/DioxusLabs/collect-assets", features = ["webp", "html"] }
 
 [features]
-default = ["hot-reload", "default-tls"]
+default = ["hot-reload"]
 router = ["dioxus-router"]
 hot-reload = ["serde_json", "futures-util"]
 web = ["dioxus-web"]
 desktop = ["dioxus-desktop"]
 warp = ["dep:warp", "ssr"]
 axum = ["dep:axum", "tower-http", "ssr"]
-salvo = ["dep:salvo", "ssr"]
-ssr = ["server_fn/ssr", "dioxus_server_macro/ssr", "tokio", "tokio-util", "dioxus-ssr", "tower", "hyper", "http", "http-body", "dioxus-router/ssr", "tokio-stream"]
+salvo = ["dep:salvo", "ssr", "http-body-util"]
+ssr = ["server_fn/ssr", "dioxus_server_macro/ssr", "tokio", "tokio-util", "tokio-stream", "dioxus-ssr", "tower", "hyper", "http", "dioxus-router?/ssr", "tower-layer", "anymap", "tracing-futures", "pin-project", "thiserror"]
 default-tls = ["server_fn/default-tls"]
 rustls = ["server_fn/rustls"]
-
-[dev-dependencies]
-dioxus-fullstack = { path = ".", features = ["router"] }

+ 1 - 2
packages/fullstack/examples/axum-hello-world/Cargo.toml

@@ -9,7 +9,6 @@ publish = false
 [dependencies]
 dioxus = { workspace = true }
 dioxus-fullstack = { workspace = true }
-axum = { version = "0.6.12", optional = true }
 serde = "1.0.159"
 simple_logger = "4.2.0"
 tracing-wasm = "0.2.1"
@@ -19,5 +18,5 @@ reqwest = "0.11.18"
 
 [features]
 default = []
-ssr = ["axum", "dioxus-fullstack/axum"]
+ssr = ["dioxus-fullstack/axum"]
 web = ["dioxus-fullstack/web"]

+ 1 - 2
packages/fullstack/examples/salvo-hello-world/Cargo.toml

@@ -10,7 +10,6 @@ publish = false
 dioxus-web = { workspace = true, features=["hydrate"], optional = true }
 dioxus = { workspace = true }
 dioxus-fullstack = { workspace = true }
-tokio = { workspace = true, features = ["full"], optional = true }
 serde = "1.0.159"
 salvo = { version = "0.63.0", optional = true }
 execute = "0.2.12"
@@ -22,5 +21,5 @@ tracing-subscriber = "0.3.17"
 
 [features]
 default = []
-ssr = ["salvo", "tokio", "dioxus-fullstack/salvo"]
+ssr = ["salvo", "dioxus-fullstack/salvo"]
 web = ["dioxus-web"]

+ 1 - 2
packages/fullstack/examples/warp-hello-world/Cargo.toml

@@ -10,7 +10,6 @@ publish = false
 dioxus-web = { workspace = true, features=["hydrate"], optional = true }
 dioxus = { workspace = true }
 dioxus-fullstack = { workspace = true }
-tokio = { workspace = true, features = ["full"], optional = true }
 serde = "1.0.159"
 warp = { version = "0.3.3", optional = true }
 execute = "0.2.12"
@@ -22,5 +21,5 @@ tracing-subscriber = "0.3.17"
 
 [features]
 default = []
-ssr = ["warp", "tokio", "dioxus-fullstack/warp"]
+ssr = ["warp", "dioxus-fullstack/warp"]
 web = ["dioxus-web"]

+ 1 - 1
packages/fullstack/src/html_storage/deserialize.rs

@@ -15,7 +15,7 @@ pub(crate) fn serde_from_bytes<T: DeserializeOwned>(string: &[u8]) -> Option<T>
         }
     };
 
-    match postcard::from_bytes(&decompressed) {
+    match ciborium::from_reader(std::io::Cursor::new(decompressed)) {
         Ok(data) => Some(data),
         Err(err) => {
             tracing::error!("Failed to deserialize: {}", err);

+ 8 - 5
packages/fullstack/src/html_storage/mod.rs

@@ -1,6 +1,6 @@
 #![allow(unused)]
 
-use std::sync::atomic::AtomicUsize;
+use std::{io::Cursor, sync::atomic::AtomicUsize};
 
 use serde::{de::DeserializeOwned, Serialize};
 
@@ -15,7 +15,8 @@ pub(crate) struct HTMLData {
 
 impl HTMLData {
     pub(crate) fn push<T: Serialize>(&mut self, value: &T) {
-        let serialized = postcard::to_allocvec(value).unwrap();
+        let mut serialized = Vec::new();
+        serialize::serde_to_writable(value, &mut serialized).unwrap();
         self.data.push(serialized);
     }
 
@@ -45,7 +46,7 @@ impl HTMLDataCursor {
         }
         let mut cursor = &self.data[current];
         self.index.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
-        match postcard::from_bytes(cursor) {
+        match ciborium::from_reader(Cursor::new(cursor)) {
             Ok(x) => Some(x),
             Err(e) => {
                 tracing::error!("Error deserializing data: {:?}", e);
@@ -57,7 +58,7 @@ impl HTMLDataCursor {
 
 #[test]
 fn serialized_and_deserializes() {
-    use postcard::to_allocvec;
+    use ciborium::{from_reader, into_writer};
 
     #[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, Clone)]
     struct Data {
@@ -97,7 +98,9 @@ fn serialized_and_deserializes() {
                 "original size: {}",
                 std::mem::size_of::<Data>() * data.len()
             );
-            println!("serialized size: {}", to_allocvec(&data).unwrap().len());
+            let mut bytes = Vec::new();
+            into_writer(&data, &mut bytes).unwrap();
+            println!("serialized size: {}", bytes.len());
             println!("compressed size: {}", as_string.len());
 
             let decoded: Vec<Data> = deserialize::serde_from_bytes(&as_string).unwrap();

+ 7 - 6
packages/fullstack/src/html_storage/serialize.rs

@@ -7,8 +7,9 @@ use base64::Engine;
 pub(crate) fn serde_to_writable<T: Serialize>(
     value: &T,
     write_to: &mut impl std::io::Write,
-) -> std::io::Result<()> {
-    let serialized = postcard::to_allocvec(value).unwrap();
+) -> Result<(), ciborium::ser::Error<std::io::Error>> {
+    let mut serialized = Vec::new();
+    ciborium::into_writer(value, &mut serialized)?;
     write_to.write_all(STANDARD.encode(serialized).as_bytes())?;
     Ok(())
 }
@@ -18,12 +19,12 @@ pub(crate) fn serde_to_writable<T: Serialize>(
 pub(crate) fn encode_props_in_element<T: Serialize>(
     data: &T,
     write_to: &mut impl std::io::Write,
-) -> std::io::Result<()> {
+) -> Result<(), ciborium::ser::Error<std::io::Error>> {
     write_to.write_all(
         r#"<meta hidden="true" id="dioxus-storage-props" data-serialized=""#.as_bytes(),
     )?;
     serde_to_writable(data, write_to)?;
-    write_to.write_all(r#"" />"#.as_bytes())
+    Ok(write_to.write_all(r#"" />"#.as_bytes())?)
 }
 
 #[cfg(feature = "ssr")]
@@ -31,10 +32,10 @@ pub(crate) fn encode_props_in_element<T: Serialize>(
 pub(crate) fn encode_in_element(
     data: &super::HTMLData,
     write_to: &mut impl std::io::Write,
-) -> std::io::Result<()> {
+) -> Result<(), ciborium::ser::Error<std::io::Error>> {
     write_to.write_all(
         r#"<meta hidden="true" id="dioxus-storage-data" data-serialized=""#.as_bytes(),
     )?;
     serde_to_writable(&data, write_to)?;
-    write_to.write_all(r#"" />"#.as_bytes())
+    Ok(write_to.write_all(r#"" />"#.as_bytes())?)
 }

+ 6 - 3
packages/fullstack/src/render.rs

@@ -65,7 +65,7 @@ impl SsrRendererPool {
                             }
                             if let Err(err) = renderer.render_to(&mut to, &vdom) {
                                 let _ = tx.send(Err(
-                                    dioxus_router::prelude::IncrementalRendererError::RenderError(
+                                    dioxus_ssr::incremental::IncrementalRendererError::RenderError(
                                         err,
                                     ),
                                 ));
@@ -236,7 +236,9 @@ impl<P: Clone + Serialize + Send + Sync + 'static> dioxus_ssr::incremental::Wrap
         to: &mut R,
     ) -> Result<(), dioxus_ssr::incremental::IncrementalRendererError> {
         // serialize the props
-        crate::html_storage::serialize::encode_props_in_element(&self.cfg.props, to)?;
+        crate::html_storage::serialize::encode_props_in_element(&self.cfg.props, to).map_err(
+            |err| dioxus_ssr::incremental::IncrementalRendererError::Other(Box::new(err)),
+        )?;
         // serialize the server state
         crate::html_storage::serialize::encode_in_element(
             &*self.server_context.html_data().map_err(|_| {
@@ -258,7 +260,8 @@ impl<P: Clone + Serialize + Send + Sync + 'static> dioxus_ssr::incremental::Wrap
                 }))
             })?,
             to,
-        )?;
+        )
+        .map_err(|err| dioxus_ssr::incremental::IncrementalRendererError::Other(Box::new(err)))?;
 
         #[cfg(all(debug_assertions, feature = "hot-reload"))]
         {

+ 8 - 7
packages/html/Cargo.toml

@@ -20,7 +20,7 @@ euclid = "0.22.7"
 enumset = "1.1.2"
 keyboard-types = "0.7"
 async-trait = "0.1.58"
-serde-value = "0.7.0"
+serde-value = { version = "0.7.0", optional = true }
 tokio = { workspace = true, features = ["fs", "io-util"], optional = true }
 rfd = { version = "0.12", optional = true }
 async-channel = "1.8.0"
@@ -56,14 +56,15 @@ serialize = [
     "euclid/serde",
     "keyboard-types/serde",
     "dioxus-core/serialize",
+    "serde-value",
 ]
 mounted = [
-    "web-sys/Element",
-    "web-sys/DomRect",
-    "web-sys/ScrollIntoViewOptions",
-    "web-sys/ScrollLogicalPosition",
-    "web-sys/ScrollBehavior",
-    "web-sys/HtmlElement",
+    "web-sys?/Element",
+    "web-sys?/DomRect",
+    "web-sys?/ScrollIntoViewOptions",
+    "web-sys?/ScrollLogicalPosition",
+    "web-sys?/ScrollBehavior",
+    "web-sys?/HtmlElement",
 ]
 eval = [
     "serde",

+ 2 - 4
packages/router/Cargo.toml

@@ -10,13 +10,10 @@ homepage = "https://dioxuslabs.com"
 keywords = ["dom", "ui", "gui", "react", "wasm"]
 
 [dependencies]
-anyhow = "1.0.66"
 dioxus = { workspace = true }
 dioxus-router-macro = { workspace = true }
 gloo = { version = "0.8.0", optional = true }
 tracing = { workspace = true }
-thiserror = { workspace = true }
-futures-util = { workspace = true }
 urlencoding = "2.1.3"
 serde = { version = "1", features = ["derive"], optional = true }
 serde_json = { version = "1.0.91", optional = true }
@@ -30,13 +27,14 @@ gloo-utils = { version = "0.1.6", optional = true }
 dioxus-liveview = { workspace = true, optional = true }
 dioxus-ssr = { workspace = true, optional = true }
 tokio = { workspace = true, features = ["full"], optional = true }
+dioxus-cli-config.workspace = true
 
 [features]
 default = ["web"]
 ssr = ["dioxus-ssr", "tokio"]
 liveview = ["dioxus-liveview", "tokio", "dep:serde", "serde_json"]
 wasm_test = []
-serde = ["dep:serde", "gloo-utils/serde"]
+serde = ["dep:serde", "gloo-utils?/serde"]
 web = ["gloo", "web-sys", "wasm-bindgen", "gloo-utils", "js-sys"]
 
 [dev-dependencies]

+ 1 - 2
packages/router/examples/simple_routes.rs

@@ -54,8 +54,7 @@ fn main() {
 #[cfg(feature = "liveview")]
 #[component]
 fn Root(cx: Scope) -> Element {
-    let history = LiveviewHistory::new(cx);
-    render! { Router::<Route> { config: || RouterConfig::default().history(history) } }
+    render! { Router::<Route> {} }
 }
 
 #[cfg(not(feature = "liveview"))]

+ 27 - 17
packages/router/src/history/liveview.rs

@@ -132,6 +132,15 @@ where
     }
 }
 
+impl<R: Routable> Default for LiveviewHistory<R>
+where
+    <R as FromStr>::Err: std::fmt::Display,
+{
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
 impl<R: Routable> LiveviewHistory<R>
 where
     <R as FromStr>::Err: std::fmt::Display,
@@ -141,10 +150,9 @@ where
     ///
     /// # Panics
     ///
-    /// Panics if not in a Liveview context.
-    pub fn new(cx: &ScopeState) -> Self {
+    /// Panics if the function is not called in a dioxus runtime with a Liveview context.
+    pub fn new() -> Self {
         Self::new_with_initial_path(
-            cx,
             "/".parse().unwrap_or_else(|err| {
                 panic!("index route does not exist:\n{}\n use LiveviewHistory::new_with_initial_path to set a custom path", err)
             }),
@@ -156,17 +164,16 @@ where
     ///
     /// # Panics
     ///
-    /// Panics if not in a Liveview context.
-    pub fn new_with_initial_path(cx: &ScopeState, initial_path: R) -> Self {
+    /// Panics if the function is not called in a dioxus runtime with a Liveview context.
+    pub fn new_with_initial_path(initial_path: R) -> Self {
         let (action_tx, action_rx) = tokio::sync::mpsc::unbounded_channel::<Action<R>>();
         let action_rx = Arc::new(Mutex::new(action_rx));
         let timeline = Arc::new(Mutex::new(Timeline::new(initial_path)));
         let updater_callback: Arc<RwLock<Arc<dyn Fn() + Send + Sync>>> =
             Arc::new(RwLock::new(Arc::new(|| {})));
 
-        let eval_provider = cx
-            .consume_context::<Rc<dyn EvalProvider>>()
-            .expect("evaluator not provided");
+        let eval_provider =
+            consume_context::<Rc<dyn EvalProvider>>().expect("evaluator not provided");
 
         let create_eval = Rc::new(move |script: &str| {
             eval_provider
@@ -175,7 +182,7 @@ where
         }) as Rc<dyn Fn(&str) -> Result<UseEval, EvalError>>;
 
         // Listen to server actions
-        cx.push_future({
+        push_future({
             let timeline = timeline.clone();
             let action_rx = action_rx.clone();
             let create_eval = create_eval.clone();
@@ -235,7 +242,7 @@ where
         });
 
         // Listen to browser actions
-        cx.push_future({
+        push_future({
             let updater = updater_callback.clone();
             let timeline = timeline.clone();
             let create_eval = create_eval.clone();
@@ -256,15 +263,16 @@ where
                         Option<State>,
                         Option<Session<R>>,
                         usize,
-                    )>(init_eval).expect("serializable state");
+                    )>(init_eval)
+                    .expect("serializable state");
                     let Ok(route) = R::from_str(&route.to_string()) else {
                         return;
                     };
                     let mut timeline = timeline.lock().expect("unpoisoned mutex");
                     let state = timeline.init(route.clone(), state, session, depth);
                     let state = serde_json::to_string(&state).expect("serializable state");
-                    let session = serde_json::to_string(&timeline.session())
-                        .expect("serializable session");
+                    let session =
+                        serde_json::to_string(&timeline.session()).expect("serializable session");
 
                     // Call the updater callback
                     (updater.read().unwrap())();
@@ -288,22 +296,24 @@ where
                         Ok(event) => event,
                         Err(_) => continue,
                     };
-                    let (route, state) = serde_json::from_value::<(String, Option<State>)>(event).expect("serializable state");
+                    let (route, state) = serde_json::from_value::<(String, Option<State>)>(event)
+                        .expect("serializable state");
                     let Ok(route) = R::from_str(&route.to_string()) else {
                         return;
                     };
                     let mut timeline = timeline.lock().expect("unpoisoned mutex");
                     let state = timeline.update(route.clone(), state);
                     let state = serde_json::to_string(&state).expect("serializable state");
-                    let session = serde_json::to_string(&timeline.session())
-                        .expect("serializable session");
+                    let session =
+                        serde_json::to_string(&timeline.session()).expect("serializable session");
 
                     let _ = create_eval(&format!(
                         r#"
                         // this does not trigger a PopState event
                         history.replaceState({state}, "", "{route}");
                         sessionStorage.setItem("liveview", '{session}');
-                    "#));
+                    "#
+                    ));
 
                     // Call the updater callback
                     (updater.read().unwrap())();

+ 24 - 0
packages/router/src/history/web.rs

@@ -13,6 +13,16 @@ use super::{
     HistoryProvider,
 };
 
+#[allow(dead_code)]
+fn base_path() -> Option<&'static str> {
+    let base_path = dioxus_cli_config::CURRENT_CONFIG
+        .as_ref()
+        .ok()
+        .and_then(|c| c.dioxus_config.web.app.base_path.as_deref());
+    tracing::trace!("Using base_path from Dioxus.toml: {:?}", base_path);
+    base_path
+}
+
 #[cfg(not(feature = "serde"))]
 #[allow(clippy::extra_unused_type_parameters)]
 fn update_scroll<R>(window: &Window, history: &History) {
@@ -160,6 +170,10 @@ impl<R: Routable> WebHistory<R> {
                 .expect("`history` can set scroll restoration");
         }
 
+        let prefix = prefix
+            .or_else(|| base_path().map(|s| s.to_string()))
+            .map(|prefix| format!("/{}", prefix.trim_matches('/')));
+
         Self {
             do_scroll_restoration,
             history,
@@ -198,6 +212,16 @@ where
         let location = self.window.location();
         let path = location.pathname().unwrap_or_else(|_| "/".into())
             + &location.search().unwrap_or("".into());
+        let path = match self.prefix {
+            None => path,
+            Some(ref prefix) => {
+                if path.starts_with(prefix) {
+                    path[prefix.len()..].to_string()
+                } else {
+                    path
+                }
+            }
+        };
         R::from_str(&path).unwrap_or_else(|err| panic!("{}", err))
     }
 

+ 16 - 3
packages/router/src/router_cfg.rs

@@ -53,10 +53,15 @@ where
 {
     pub(crate) fn get_history(self) -> Box<dyn HistoryProvider<R>> {
         self.history.unwrap_or_else(|| {
-            #[cfg(all(target_arch = "wasm32", feature = "web"))]
+            #[cfg(all(not(feature = "liveview"), target_arch = "wasm32", feature = "web"))]
             let history = Box::<WebHistory<R>>::default();
-            #[cfg(not(all(target_arch = "wasm32", feature = "web")))]
+            #[cfg(all(
+                not(feature = "liveview"),
+                any(not(target_arch = "wasm32"), not(feature = "web"))
+            ))]
             let history = Box::<MemoryHistory<R>>::default();
+            #[cfg(feature = "liveview")]
+            let history = Box::<LiveviewHistory<R>>::default();
             history
         })
     }
@@ -83,9 +88,17 @@ where
 {
     pub(crate) fn take_history(&mut self) -> Box<dyn AnyHistoryProvider> {
         self.history.take().unwrap_or_else(|| {
+            // If we are on wasm32 and the web feature is enabled, use the web history.
             #[cfg(all(target_arch = "wasm32", feature = "web"))]
             let history = Box::<AnyHistoryProviderImplWrapper<R, WebHistory<R>>>::default();
-            #[cfg(not(all(target_arch = "wasm32", feature = "web")))]
+            // If we are not on wasm32 and the liveview feature is enabled, use the liveview history.
+            #[cfg(all(feature = "liveview", not(target_arch = "wasm32")))]
+            let history = Box::<AnyHistoryProviderImplWrapper<R, LiveviewHistory<R>>>::default();
+            // If neither of the above are true, use the memory history.
+            #[cfg(all(
+                not(all(target_arch = "wasm32", feature = "web")),
+                not(all(feature = "liveview", not(target_arch = "wasm32"))),
+            ))]
             let history = Box::<AnyHistoryProviderImplWrapper<R, MemoryHistory<R>>>::default();
             history
         })

+ 2 - 2
packages/rsx/Cargo.toml

@@ -14,7 +14,7 @@ keywords = ["dom", "ui", "gui", "react"]
 
 [dependencies]
 proc-macro2 = { version = "1.0", features = ["span-locations"] }
-dioxus-core = { workspace = true}
+dioxus-core = { workspace = true, optional = true }
 syn = { version = "2.0", features = ["full", "extra-traits"] }
 quote = { version = "1.0" }
 serde = { version = "1.0", features = ["derive"], optional = true }
@@ -24,6 +24,6 @@ tracing.workspace = true
 
 [features]
 default = ["html"]
-hot_reload = ["krates", "internment"]
+hot_reload = ["krates", "internment", "dioxus-core"]
 serde = ["dep:serde"]
 html = []

+ 1 - 2
packages/ssr/Cargo.toml

@@ -17,13 +17,12 @@ rustc-hash = "1.1.0"
 lru = "0.10.0"
 tracing = { workspace = true }
 http = "0.2.9"
-tokio = { version = "1.28", features = ["full"], optional = true }
+tokio = { version = "1.28", features = ["fs", "io-util"], optional = true }
 async-trait = "0.1.58"
 serde_json = { version = "1.0" }
 
 [dev-dependencies]
 dioxus = { workspace = true }
-thiserror = { workspace = true }
 tracing = { workspace = true }
 fern = { version = "0.6.0", features = ["colored"] }
 anyhow = "1.0"