iet-ui-build
tooling tooling official
Build-script support for compiling local CSS with the pinned Tailwind binary.
CoreFeaturesIntegrationsStacksTooling
Used byno framework crate yetexamples/htmx-starter
iet-ui-buildtoolingTailwind build helperDepends onnothing — it stands alone
How to use it
iet_ui_build::compile(css, sources) is a build-script helper that runs the pinned standalone Tailwind CSS v4.1.11 binary over your application CSS and source tree. It writes OUT_DIR/ui.css plus OUT_DIR/ui-assets.rs (containing pub const UI_HASH: &str), emits cargo:rerun-if-changed directives, and never downloads or installs the tool itself. Relative paths resolve against CARGO_MANIFEST_DIR.
// examples/htmx-starter/crates/task-adapter-htmx/build.rs
- The input CSS must contain
@import "tailwindcss" source(none);(single quotes accepted) to disable implicit source scanning. sourcesare existing files or directories, not globs; directories are expanded to explicit@sourceentries.- Provide the binary via
FW_TAILWIND_BINor puttailwindcssonPATH; a missing or wrong-version binary fails with an actionable error. - Consume the result with
include_bytes!(concat!(env!("OUT_DIR"), "/ui.css")).
How it works
compile validates the input, resolves and tracks the CSS and source trees, locates the pinned v4.1.11 binary via FW_TAILWIND_BIN or PATH, runs it with --minify, and stages the outputs before renaming them into place.
flowchart LR B["build.rs calls compile"] --> V["require @import tailwindcss source none"] V --> T["track_tree and rerun-if-changed"] T --> X["Tailwind binary v4.1.11"] W["FW_TAILWIND_BIN or PATH"] --> X X --> M["--minify to temporary css"] M --> O["OUT_DIR/ui.css"] M --> H["SHA-256 digest"] H --> A["OUT_DIR/ui-assets.rs with UI_HASH"]
What it implements
- Concrete mechanism; see the public API below.
What's inside
Modules
src/lib.rs
Public API
(root)
pub fn compile(css: impl AsRef<Path>, sources: &[&str]) -> Result<(), Box<dyn Error>>— Compile CSS toOUT_DIR/ui.cssand emitOUT_DIR/ui-assets.rscontainingpub const UI_HASH: &str, the lowercase SHA-256 digest of the CSS bytes. Relative CSS, source, and explicit executable paths resolve againstCARGO_MANIFEST_DIR. Symlinks andtarget,.git, andbefore-refactortrees are excluded. Missing or excluded explicit inputs are errors. CSS imports outside the input's directory tree need their own Cargo tracking. Outputs are staged and renamed only after successful compilation; the two final renames are not an atomic transaction.
Impl map
Drop for Fixture
Depends on
- No other framework crate: it stands alone.
External crates: sha2
Used by
- No other framework crate depends on it directly.
In this repository
examples/htmx-starter
Source: crates/build/iet-ui-build