crates.io ↗

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 helper
Depends 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.

rust
// examples/htmx-starter/crates/task-adapter-htmx/build.rs
fn main() {
    iet_ui_build::compile(
        "assets/app.css",
        &[
            "src",
            "../project-adapter-htmx/src",
            "../../../../crates/features/iet-ui/src",
        ],
    )
    .expect("application CSS compilation failed");
}
  • The input CSS must contain @import "tailwindcss" source(none); (single quotes accepted) to disable implicit source scanning.
  • sources are existing files or directories, not globs; directories are expanded to explicit @source entries.
  • Provide the binary via FW_TAILWIND_BIN or put tailwindcss on PATH; 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 to OUT_DIR/ui.css and emit OUT_DIR/ui-assets.rs containing pub const UI_HASH: &str, the lowercase SHA-256 digest of the CSS bytes. Relative CSS, source, and explicit executable paths resolve against CARGO_MANIFEST_DIR. Symlinks and target, .git, and before-refactor trees 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