mini_build/lib.rs
1//! Builds the directory a static server serves.
2//!
3//! This crate takes source folders of CSS, JS, and hand-authored assets and produces one
4//! output directory: CSS bundled and/or minified, JS minified or bundled from an entry
5//! point, everything else mirrored byte-for-byte. It delegates transformation to external
6//! CLI tools (`lightningcss`, `esbuild`) rather than embedding a bundler, keeping the
7//! crate free of any particular bundler's dependency weight and release cadence.
8//!
9//! It speaks no HTTP and knows nothing about serving. It composes with a static server —
10//! `mini-static`, or any other — through the filesystem: this crate writes a directory,
11//! the server serves one. Neither depends on the other.
12//!
13//! # Scope
14//!
15//! *Produce the directory a static server serves.* That sentence decides what belongs
16//! here: an asset folder mirrored byte-for-byte is in scope even though nothing
17//! transforms it, because the output directory is not complete without it. Serving that
18//! directory, watching it for a browser's benefit, or deciding cache headers for it are
19//! all somebody else's job.
20//!
21//! # Example
22//!
23//! ```no_run
24//! # fn example() -> Result<(), Box<dyn std::error::Error>> {
25//! use mini_build::{Builder, CssOptions, CssTool};
26//! use std::path::Path;
27//!
28//! Builder::new(Path::new("./public"))?
29//! .source_folder(Path::new("./src/styles"))?
30//! .css_tool(CssTool::LightningCss, CssOptions::default())
31//! .build()?;
32//! # Ok(())
33//! # }
34//! ```
35
36mod builder;
37mod change;
38mod css;
39mod error;
40mod js;
41mod source;
42mod tool;
43mod watch;
44
45pub use builder::Builder;
46pub use change::{Broadcaster, ChangeEvent, ChangeType};
47pub use css::{CssError, CssOptions, CssTool};
48pub use error::BuildError;
49pub use js::{JsError, JsOptions, JsTool};
50pub use source::{SourceError, SourcePipeline};
51pub use tool::ToolError;
52pub use watch::WatchHandle;