Przeglądaj źródła

fix(tauri) ignore just the distDir's root `index.html` (#791)

Lucas Fernandes Nogueira 5 lat temu
rodzic
commit
aad60f59c7
2 zmienionych plików z 20 dodań i 2 usunięć
  1. 5 0
      .changes/tauri-includedir-fix.md
  2. 15 2
      tauri/build.rs

+ 5 - 0
.changes/tauri-includedir-fix.md

@@ -0,0 +1,5 @@
+---
+"tauri": patch
+---
+
+Properly ignore the `${distDir}/index.html` asset from the asset embbeding. Previously every asset with name matching `/(.+)index.html$/g` were ignored.

+ 15 - 2
tauri/build.rs

@@ -21,6 +21,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
   match env::var_os("TAURI_DIST_DIR") {
     Some(dist_path) => {
       let dist_path_string = dist_path.into_string().unwrap();
+      let dist_path = Path::new(&dist_path_string);
 
       println!("cargo:rerun-if-changed={}", dist_path_string);
 
@@ -36,10 +37,22 @@ pub fn main() -> Result<(), Box<dyn Error>> {
       };
 
       // the index.html is parsed so we always ignore it
-      inlined_assets.push("index.html".to_string());
+      inlined_assets.push(
+        dist_path
+          .join("index.html")
+          .into_os_string()
+          .into_string()
+          .expect("failed to convert dist path to string"),
+      );
       if cfg!(feature = "no-server") {
         // on no-server we include_str() the index.tauri.html on the runner
-        inlined_assets.push("index.tauri.html".to_string());
+        inlined_assets.push(
+          dist_path
+            .join("index.tauri.html")
+            .into_os_string()
+            .into_string()
+            .expect("failed to convert dist path to string"),
+        );
       }
 
       // include assets