mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-01 10:01:07 +02:00
fix(tauri-build): rerun if assets or icons change (#4910)
This commit is contained in:
committed by
GitHub
parent
0e925fd8f0
commit
ff8fd7619a
5
.changes/build-codegen-rerun.md
Normal file
5
.changes/build-codegen-rerun.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri-build": patch
|
||||
---
|
||||
|
||||
Rerun codegen if assets or icons change.
|
||||
@@ -10,6 +10,7 @@ use std::{
|
||||
path::PathBuf,
|
||||
};
|
||||
use tauri_codegen::{context_codegen, ContextData};
|
||||
use tauri_utils::config::{AppUrl, WindowUrl};
|
||||
|
||||
// TODO docs
|
||||
/// A builder for generating a Tauri application context during compile time.
|
||||
@@ -92,6 +93,40 @@ impl CodegenContext {
|
||||
/// Non-panicking [`Self::build`]
|
||||
pub fn try_build(self) -> Result<PathBuf> {
|
||||
let (config, config_parent) = tauri_codegen::get_config(&self.config_path)?;
|
||||
|
||||
// rerun if changed
|
||||
let app_url = if self.dev {
|
||||
&config.build.dev_path
|
||||
} else {
|
||||
&config.build.dist_dir
|
||||
};
|
||||
match app_url {
|
||||
AppUrl::Url(WindowUrl::App(p)) => {
|
||||
println!("cargo:rerun-if-changed={}", config_parent.join(p).display());
|
||||
}
|
||||
AppUrl::Files(files) => {
|
||||
for path in files {
|
||||
println!(
|
||||
"cargo:rerun-if-changed={}",
|
||||
config_parent.join(path).display()
|
||||
);
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
for icon in &config.tauri.bundle.icon {
|
||||
println!(
|
||||
"cargo:rerun-if-changed={}",
|
||||
config_parent.join(icon).display()
|
||||
);
|
||||
}
|
||||
if let Some(tray_icon) = config.tauri.system_tray.as_ref().map(|t| &t.icon_path) {
|
||||
println!(
|
||||
"cargo:rerun-if-changed={}",
|
||||
config_parent.join(tray_icon).display()
|
||||
);
|
||||
}
|
||||
|
||||
let code = context_codegen(ContextData {
|
||||
dev: self.dev,
|
||||
config,
|
||||
|
||||
@@ -293,10 +293,6 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
|
||||
)?;
|
||||
}
|
||||
|
||||
for icon in &config.tauri.bundle.icon {
|
||||
println!("cargo:rerun-if-changed={}", icon);
|
||||
}
|
||||
|
||||
#[allow(unused_mut, clippy::redundant_clone)]
|
||||
let mut resources = config.tauri.bundle.resources.clone().unwrap_or_default();
|
||||
#[cfg(windows)]
|
||||
|
||||
Reference in New Issue
Block a user