Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions packages/cli/src/cli/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use anyhow::{anyhow, Context};
use path_absolutize::Absolutize;
use std::collections::HashMap;
use tauri_bundler::{BundleBinary, BundleSettings, PackageSettings, SettingsBuilder};
use walkdir::WalkDir;

use super::*;

Expand Down Expand Up @@ -187,21 +188,24 @@ impl Bundle {

let asset_dir = bundle.build.asset_dir();
if asset_dir.exists() {
let asset_dir_entries = std::fs::read_dir(&asset_dir)
.with_context(|| format!("failed to read asset directory {:?}", asset_dir))?;
for entry in asset_dir_entries.flatten() {
let old = entry
.path()
.canonicalize()
.with_context(|| format!("Failed to canonicalize {entry:?}"))?;
let new = PathBuf::from("assets").join(old.file_name().expect("Filename to exist"));
tracing::debug!("Bundled asset: {old:?} -> {new:?}");

bundle_settings
.resources_map
.as_mut()
.expect("to be set")
.insert(old.display().to_string(), new.display().to_string());
for entry in WalkDir::new(&asset_dir) {
let entry = entry.unwrap();
let path = entry.path();

if path.is_file() {
let old = path
.canonicalize()
.with_context(|| format!("Failed to canonicalize {entry:?}"))?;
let new =
PathBuf::from("assets").join(path.strip_prefix(&asset_dir).unwrap_or(path));

tracing::debug!("Bundled asset: {old:?} -> {new:?}");
bundle_settings
.resources_map
.as_mut()
.expect("to be set")
.insert(old.display().to_string(), new.display().to_string());
}
}
}

Expand Down
Loading