Browse Source

disable asset patching in cargo run for mobile

Evan Almloff 1 year ago
parent
commit
1a36409922

+ 2 - 2
packages/desktop/Cargo.toml

@@ -38,9 +38,9 @@ futures-util = { workspace = true }
 urlencoding = "2.1.2"
 async-trait = "0.1.68"
 
-assets-cli-support = { git = "https://github.com/DioxusLabs/collect-assets", features = ["webp", "html"] }
-
 [target.'cfg(any(target_os = "windows",target_os = "macos",target_os = "linux",target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
+# This is only for debug mode, and it appears mobile does not support some packages this uses
+assets-cli-support = { git = "https://github.com/DioxusLabs/collect-assets", features = ["webp", "html"] }
 rfd = "0.11.3"
 
 [target.'cfg(target_os = "ios")'.dependencies]

+ 24 - 2
packages/desktop/src/collect_assets.rs

@@ -1,5 +1,16 @@
 pub fn copy_assets() {
-    #[cfg(debug_assertions)]
+    #[cfg(all(
+        debug_assertions,
+        any(
+            target_os = "windows",
+            target_os = "macos",
+            target_os = "linux",
+            target_os = "dragonfly",
+            target_os = "freebsd",
+            target_os = "netbsd",
+            target_os = "openbsd"
+        )
+    ))]
     {
         use assets_cli_support::AssetManifest;
         use assets_cli_support::AssetManifestExt;
@@ -22,7 +33,18 @@ pub fn copy_assets() {
             println!("Copied assets to {}", asset_location.display());
         }
     }
-    #[cfg(not(debug_assertions))]
+    #[cfg(not(all(
+        debug_assertions,
+        any(
+            target_os = "windows",
+            target_os = "macos",
+            target_os = "linux",
+            target_os = "dragonfly",
+            target_os = "freebsd",
+            target_os = "netbsd",
+            target_os = "openbsd"
+        )
+    )))]
     {
         println!(
             "Skipping assets in release mode. You compile assets with the dioxus-cli in release mode"

+ 24 - 2
packages/desktop/src/protocol.rs

@@ -74,13 +74,35 @@ pub(super) fn desktop_handler(
 
                 #[allow(unused_mut)]
                 let mut head = custom_head.unwrap_or_default();
-                #[cfg(debug_assertions)]
+                #[cfg(all(
+                    debug_assertions,
+                    any(
+                        target_os = "windows",
+                        target_os = "macos",
+                        target_os = "linux",
+                        target_os = "dragonfly",
+                        target_os = "freebsd",
+                        target_os = "netbsd",
+                        target_os = "openbsd"
+                    )
+                ))]
                 {
                     use assets_cli_support::AssetManifestExt;
                     let manifest = assets_cli_support::AssetManifest::load();
                     head += &manifest.head();
                 }
-                #[cfg(not(debug_assertions))]
+                #[cfg(not(all(
+                    debug_assertions,
+                    any(
+                        target_os = "windows",
+                        target_os = "macos",
+                        target_os = "linux",
+                        target_os = "dragonfly",
+                        target_os = "freebsd",
+                        target_os = "netbsd",
+                        target_os = "openbsd"
+                    )
+                )))]
                 {
                     if let Some(assets_head) = assets_head {
                         head += &assets_head;

+ 24 - 2
packages/desktop/src/webview.rs

@@ -19,11 +19,33 @@ pub fn build(
     let index_file = cfg.custom_index.clone();
     let root_name = cfg.root_name.clone();
     let assets_head = {
-        #[cfg(debug_assertions)]
+        #[cfg(all(
+            debug_assertions,
+            any(
+                target_os = "windows",
+                target_os = "macos",
+                target_os = "linux",
+                target_os = "dragonfly",
+                target_os = "freebsd",
+                target_os = "netbsd",
+                target_os = "openbsd"
+            )
+        ))]
         {
             None
         }
-        #[cfg(not(debug_assertions))]
+        #[cfg(not(all(
+            debug_assertions,
+            any(
+                target_os = "windows",
+                target_os = "macos",
+                target_os = "linux",
+                target_os = "dragonfly",
+                target_os = "freebsd",
+                target_os = "netbsd",
+                target_os = "openbsd"
+            )
+        )))]
         {
             let head = crate::protocol::get_asset_root_or_default();
             let head = head.join("dist/__assets_head.html");