pub struct SourcePipeline { /* private fields */ }Expand description
Routes source-folder file changes to the pipeline that turns them into served output.
The watcher layer runs over source folders only. The designated output dir is never watched and never a trigger: every pipeline below writes its own output, and a pipeline that listened to its own output would re-trigger itself forever (the feedback-loop bug this design fixes). Instead, after a build finishes, the pipeline broadcasts the reload event for the output it wrote, so the browser still hot-swaps/reloads.
CSS and JS are each independently configured via an optional (tool, options) pair.
options.bundle() selects between two disjoint modes per language: bundle (a single
discovered/entry-driven output, rebuilt in full on any relevant change) or per-file
(every source file mirrored independently into the output dir).
asset_folders are a third, simpler kind of source: every file under one (any
extension, no transformation) is mirrored byte-identical into the output dir,
preserving its path relative to the asset folder — for hand-authored static files
(index.html, images) that should live outside the served/output dir as source,
same separation the CSS/JS pipelines already have, without needing a CSS/JS tool.
Implementations§
Source§impl SourcePipeline
impl SourcePipeline
pub fn new( source_folders: Vec<PathBuf>, bundle_roots: Vec<PathBuf>, asset_folders: Vec<PathBuf>, output_dir: PathBuf, css_tool: Option<(CssTool, CssOptions)>, js_tool: Option<(JsTool, JsOptions)>, prune_output: bool, broadcaster: Broadcaster, ) -> Self
Sourcepub fn full_build(&self) -> Result<(), SourceError>
pub fn full_build(&self) -> Result<(), SourceError>
Rebuild every enabled output once, then prune stale output if configured.
Runs at server startup. Never during live-reload — see Self::prune_stale_output.
Sourcepub fn process_change(
&self,
path: &Path,
change_type: &ChangeType,
) -> Result<(), SourceError>
pub fn process_change( &self, path: &Path, change_type: &ChangeType, ) -> Result<(), SourceError>
Handle a single change event for path (which must be under a watched source
folder or import root), rebuilding output as needed and broadcasting the reload
event for whatever was written.