Skip to main content

process_batch

Function process_batch 

Source
pub fn process_batch(
    batch: &ChangeBatch,
    graph: &DepGraph,
    output_dir: &Path,
) -> BatchOutcome
Expand description

Policy table: turn a ChangeBatch + a DepGraph into the right HMR frame.

Rules:

  • All CSS → hmr-css (AC2) — list every changed .css path.
  • Markdown / HTML content (no templates) → hmr-html (AC3) — list invalidated output URLs from the dep graph.
  • Template touched → hmr-html if the dep graph resolves affected pages (AC4); falls back to reload if no pages are linked (e.g. a brand-new template).
  • Mixed CSS + content → reload to keep the protocol simple.
  • All other (data, fonts, images that aren’t fingerprinted) → reload so the user always sees the latest build.

§Examples

use ssg::dev_server::process_batch;
use ssg::depgraph::DepGraph;
use ssg::event_watch::ChangeBatch;
use std::path::Path;

let batch = ChangeBatch { paths: vec![] };
let outcome = process_batch(&batch, &DepGraph::new(), Path::new("build"));
assert!(outcome.frame.is_none());