Browse Source

Fix/includedir (#751)

* fix(tauri) assets embedding regression

* fix(tauri) fix & optimize embedded assets
Lucas Fernandes Nogueira 5 năm trước cách đây
mục cha
commit
c3b5c1fdf8
4 tập tin đã thay đổi với 19 bổ sung4 xóa
  1. 6 0
      .changes/assets-fix.md
  2. 2 2
      cli/tauri.js/src/runner.ts
  3. 1 1
      tauri/Cargo.toml
  4. 10 1
      tauri/build.rs

+ 6 - 0
.changes/assets-fix.md

@@ -0,0 +1,6 @@
+---
+"tauri.js": patch
+"tauri": patch
+---
+
+Fixes the assets embedding into the binary.

+ 2 - 2
cli/tauri.js/src/runner.ts

@@ -141,7 +141,7 @@ class Runner {
       inlinedAssets = (await this.__parseHtml(cfg, devPath)).inlinedAssets
     }
 
-    process.env.TAURI_INLINED_ASSSTS = inlinedAssets.join('|')
+    process.env.TAURI_INLINED_ASSETS = inlinedAssets.join('|')
 
     this.devPath = devPath
 
@@ -225,7 +225,7 @@ class Runner {
     this.__rewriteManifest(cargoManifest)
 
     const inlinedAssets = (await this.__parseHtml(cfg, cfg.build.distDir)).inlinedAssets
-    process.env.TAURI_INLINED_ASSSTS = inlinedAssets.join('|')
+    process.env.TAURI_INLINED_ASSETS = inlinedAssets.join('|')
 
     const features = [
       cfg.tauri.embeddedServer.active ? 'embedded-server' : 'no-server'

+ 1 - 1
tauri/Cargo.toml

@@ -36,7 +36,7 @@ once_cell = "1.4.0"
 tauri-api = { version = "0.7", path = "../tauri-api" }
 
 [build-dependencies]
-tauri_includedir_codegen = "0.6.1"
+tauri_includedir_codegen = "0.6.2"
 cfg_aliases = "0.1.0"
 
 [dev-dependencies]

+ 10 - 1
tauri/build.rs

@@ -24,15 +24,24 @@ pub fn main() -> Result<(), Box<dyn Error>> {
 
       println!("cargo:rerun-if-changed={}", dist_path_string);
 
-      let inlined_assets = match std::env::var_os("TAURI_INLINED_ASSETS") {
+      let mut inlined_assets = match std::env::var_os("TAURI_INLINED_ASSETS") {
         Some(assets) => assets
           .into_string()
           .unwrap()
           .split('|')
           .map(|s| s.to_string())
+          .filter(|s| s != "")
           .collect(),
         None => Vec::new(),
       };
+
+      // the index.html is parsed so we always ignore it
+      inlined_assets.push("index.html".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());
+      }
+
       // include assets
       tauri_includedir_codegen::start("ASSETS")
         .dir(