mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-03 10:11:15 +02:00
fix: asset resolution on debug mode
This commit is contained in:
@@ -14,11 +14,12 @@ pub struct ContextData {
|
||||
/// Build an `AsTauriContext` implementation for including in application code.
|
||||
pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsError> {
|
||||
let ContextData {
|
||||
config,
|
||||
mut config,
|
||||
config_parent,
|
||||
struct_ident,
|
||||
} = data;
|
||||
let dist_dir = config_parent.join(&config.build.dist_dir);
|
||||
config.build.dist_dir = dist_dir.to_string_lossy().to_string();
|
||||
|
||||
// generate the assets inside the dist dir into a perfect hash function
|
||||
let assets = EmbeddedAssets::new(&dist_dir)?;
|
||||
|
||||
@@ -216,17 +216,13 @@ pub(super) fn build_webview<A: ApplicationExt + 'static>(
|
||||
.canonicalize()
|
||||
.or_else(|_| Err(crate::Error::AssetNotFound(path.clone())))
|
||||
.and_then(|pathbuf| {
|
||||
if pathbuf.is_file() && pathbuf.starts_with(&dist_dir) {
|
||||
match std::fs::read(pathbuf) {
|
||||
Ok(asset) => return Ok(asset),
|
||||
Err(e) => {
|
||||
#[cfg(debug_assertions)]
|
||||
eprintln!("Error reading asset from dist: {:?}", e); // TODO log::error!
|
||||
}
|
||||
match std::fs::read(pathbuf) {
|
||||
Ok(asset) => Ok(asset),
|
||||
Err(e) => {
|
||||
eprintln!("Error reading asset from dist: {:?}", e); // TODO log::error!
|
||||
Err(crate::Error::AssetNotFound(path.clone()))
|
||||
}
|
||||
}
|
||||
|
||||
Err(crate::Error::AssetNotFound(path))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user