@@ -21,6 +21,7 @@ use anyhow::Context;
2121#[ cfg( target_os = "linux" ) ]
2222use heck:: ToKebabCase ;
2323use log:: warn;
24+ use log:: { debug, info} ;
2425use notify:: { watcher, DebouncedEvent , RecursiveMode , Watcher } ;
2526use serde:: Deserialize ;
2627use shared_child:: SharedChild ;
@@ -461,20 +462,43 @@ impl Rust {
461462 let process = Arc :: new ( Mutex :: new ( child) ) ;
462463 let ( tx, rx) = channel ( ) ;
463464 let tauri_path = tauri_dir ( ) ;
465+ let workspace_path = get_workspace_dir ( & tauri_path) ;
466+
467+ let watch_folders = if tauri_path == workspace_path {
468+ vec ! [ tauri_path]
469+ } else {
470+ let cargo_settings = CargoSettings :: load ( & workspace_path) ?;
471+ cargo_settings
472+ . workspace
473+ . as_ref ( )
474+ . map ( |w| {
475+ w. members
476+ . clone ( )
477+ . unwrap_or_default ( )
478+ . into_iter ( )
479+ . map ( |p| workspace_path. join ( p) )
480+ . collect ( )
481+ } )
482+ . unwrap_or_else ( || vec ! [ tauri_path] )
483+ } ;
464484
465485 let mut watcher = watcher ( tx, Duration :: from_secs ( 1 ) ) . unwrap ( ) ;
466- lookup ( & tauri_path, |file_type, path| {
467- if path != tauri_path {
468- let _ = watcher. watch (
469- path,
470- if file_type. is_dir ( ) {
471- RecursiveMode :: Recursive
472- } else {
473- RecursiveMode :: NonRecursive
474- } ,
475- ) ;
476- }
477- } ) ;
486+ for path in watch_folders {
487+ info ! ( "Watching {} for changes..." , path. display( ) ) ;
488+ lookup ( & path, |file_type, p| {
489+ if p != path {
490+ debug ! ( "Watching {} for changes..." , p. display( ) ) ;
491+ let _ = watcher. watch (
492+ p,
493+ if file_type. is_dir ( ) {
494+ RecursiveMode :: Recursive
495+ } else {
496+ RecursiveMode :: NonRecursive
497+ } ,
498+ ) ;
499+ }
500+ } ) ;
501+ }
478502
479503 loop {
480504 let on_exit = on_exit. clone ( ) ;
0 commit comments