diff --git a/cli/tauri.js/src/helpers/tauri-config.ts b/cli/tauri.js/src/helpers/tauri-config.ts index e5dc425bf..33836ed0e 100644 --- a/cli/tauri.js/src/helpers/tauri-config.ts +++ b/cli/tauri.js/src/helpers/tauri-config.ts @@ -1,4 +1,4 @@ -import { existsSync } from 'fs-extra' +import { existsSync, readFileSync } from 'fs-extra' import { TauriConfig } from 'types' import merge from 'webpack-merge' import logger from '../helpers/logger' @@ -21,7 +21,7 @@ const getTauriConfig = (cfg: Partial): TauriConfig => { ) process.exit(1) } - const tauriConf = nonWebpackRequire(tauriConfPath) as TauriConfig + const tauriConf = JSON.parse(readFileSync(tauriConfPath).toString()) as TauriConfig const pkg = nonWebpackRequire(pkgPath) as { productName: string } const config = merge( diff --git a/tauri/build.rs b/tauri/build.rs index 309a5d542..9e0f89fbe 100644 --- a/tauri/build.rs +++ b/tauri/build.rs @@ -1,5 +1,6 @@ #[cfg(any(feature = "embedded-server", feature = "no-server"))] pub fn main() { + shared(); match std::env::var_os("TAURI_DIST_DIR") { Some(dist_path) => { let dist_path_string = dist_path.into_string().unwrap(); @@ -29,4 +30,14 @@ pub fn main() { } #[cfg(not(any(feature = "embedded-server", feature = "no-server")))] -pub fn main() {} +pub fn main() { + shared(); +} + +fn shared() { + if let Some(tauri_dir) = std::env::var_os("TAURI_DIR") { + let mut tauri_path = std::path::PathBuf::from(tauri_dir); + tauri_path.push("tauri.conf.json"); + println!("cargo:rerun-if-changed={:?}", tauri_path); + } +}