Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/content/documentation/getting-started/cli-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ a hard refresh if possible. If you are using WSL2 on Windows, make sure to store
Some changes cannot be handled automatically and thus live reload may not always work. If you
fail to see your change or get an error, try restarting `zola serve`.

By default, the live reload will be debounced by one full second so as to more
gracefully handle multiple changes to your input files in rapid succession. You
have control over that debouncing duration with the `--debounce <duration_ms>`
flag.
You may use `-d1` to (virtually) disable it altogether: for technical reasons
(and keeping things simple), a "debounce" of 0 is not supported.

You can also point to a config file other than `config.toml` like so (note that the position of the `config` option is important):

```bash
Expand Down
4 changes: 4 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ pub enum Command {
/// Extra path to watch for changes, relative to the project root.
#[clap(long)]
extra_watch_path: Vec<String>,

/// Debounce time in milliseconds for the file watcher (at least 1ms)
#[clap(short = 'd', long, default_value_t = 1000, value_parser = clap::value_parser!(u64).range(1..))]
debounce: u64,
},

/// Try to build the project without rendering it. Checks links
Expand Down
3 changes: 2 additions & 1 deletion src/cmd/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ pub fn serve(
no_port_append: bool,
utc_offset: UtcOffset,
extra_watch_paths: Vec<String>,
debounce: u64,
) -> Result<()> {
let start = Instant::now();
let (mut site, bind_address, constructed_base_url) = create_new_site(
Expand Down Expand Up @@ -481,7 +482,7 @@ pub fn serve(

// Setup watchers
let (tx, rx) = channel();
let mut debouncer = new_debouncer(Duration::from_secs(1), /*tick_rate=*/ None, tx).unwrap();
let mut debouncer = new_debouncer(Duration::from_millis(debounce), None, tx).unwrap();

// We watch for changes on the filesystem for every entry in watch_this
// Will fail if either:
Expand Down
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ fn main() {
fast,
no_port_append,
extra_watch_path,
debounce,
} => {
if port != 1111 && !port_is_available(interface, port) {
console::error("The requested port is not available");
Expand Down Expand Up @@ -119,6 +120,7 @@ fn main() {
no_port_append,
UtcOffset::current_local_offset().unwrap_or(UtcOffset::UTC),
extra_watch_path,
debounce,
) {
messages::unravel_errors("Failed to serve the site", &e);
std::process::exit(1);
Expand Down