diff --git a/src/cmd/watch.rs b/src/cmd/watch.rs index 9336af77..f5cf37f8 100644 --- a/src/cmd/watch.rs +++ b/src/cmd/watch.rs @@ -146,6 +146,10 @@ where // Add the book.toml file to the watcher if it exists let _ = watcher.watch(book.root.join("book.toml"), NonRecursive); + for dir in &book.config.build.extra_watch_dirs { + let _ = watcher.watch(dir, Recursive); + } + info!("Listening for changes..."); loop { diff --git a/src/config.rs b/src/config.rs index b7d03d1a..7f4adc42 100644 --- a/src/config.rs +++ b/src/config.rs @@ -437,6 +437,8 @@ pub struct BuildConfig { /// Should the default preprocessors always be used when they are /// compatible with the renderer? pub use_default_preprocessors: bool, + /// Extra directories to trigger rebuild when watching/serving + pub extra_watch_dirs: Vec, } impl Default for BuildConfig { @@ -445,6 +447,7 @@ impl Default for BuildConfig { build_dir: PathBuf::from("book"), create_missing: true, use_default_preprocessors: true, + extra_watch_dirs: Vec::new(), } } } @@ -770,6 +773,7 @@ mod tests { build_dir: PathBuf::from("outputs"), create_missing: false, use_default_preprocessors: true, + extra_watch_dirs: Vec::new(), }; let rust_should_be = RustConfig { edition: None }; let playground_should_be = Playground { @@ -980,6 +984,7 @@ mod tests { build_dir: PathBuf::from("my-book"), create_missing: true, use_default_preprocessors: true, + extra_watch_dirs: Vec::new(), }; let html_should_be = HtmlConfig {