From c3b5c1fdf8eba968583a170d215e043a5efcface Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Sun, 5 Jul 2020 01:45:07 -0300 Subject: [PATCH] Fix/includedir (#751) * fix(tauri) assets embedding regression * fix(tauri) fix & optimize embedded assets --- .changes/assets-fix.md | 6 ++++++ cli/tauri.js/src/runner.ts | 4 ++-- tauri/Cargo.toml | 2 +- tauri/build.rs | 11 ++++++++++- 4 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 .changes/assets-fix.md diff --git a/.changes/assets-fix.md b/.changes/assets-fix.md new file mode 100644 index 000000000..e3e0dc6a2 --- /dev/null +++ b/.changes/assets-fix.md @@ -0,0 +1,6 @@ +--- +"tauri.js": patch +"tauri": patch +--- + +Fixes the assets embedding into the binary. diff --git a/cli/tauri.js/src/runner.ts b/cli/tauri.js/src/runner.ts index 116b4b584..915326652 100644 --- a/cli/tauri.js/src/runner.ts +++ b/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' diff --git a/tauri/Cargo.toml b/tauri/Cargo.toml index 1df20c92f..0ad05d089 100644 --- a/tauri/Cargo.toml +++ b/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] diff --git a/tauri/build.rs b/tauri/build.rs index 86aed2254..7a53e9944 100644 --- a/tauri/build.rs +++ b/tauri/build.rs @@ -24,15 +24,24 @@ pub fn main() -> Result<(), Box> { 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(