فهرست منبع

fix(tauri.js) properly reflect tauri.conf changes on `tauri dev` (#672)

Lucas Fernandes Nogueira 5 سال پیش
والد
کامیت
4975497dad
2فایلهای تغییر یافته به همراه14 افزوده شده و 3 حذف شده
  1. 2 2
      cli/tauri.js/src/helpers/tauri-config.ts
  2. 12 1
      tauri/build.rs

+ 2 - 2
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>): 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(

+ 12 - 1
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);
+  }
+}