kick-rs-assets
Typed asset manifest + compile-time embedding for kick-rs.
Two primitives for shipping static assets with a kick-rs app:
AssetManifest— load a flat{key → hashed-filename}JSON manifest (the kind webpack / vite / esbuild emit), then resolve logical keys to cache-busted URLs.embed_assets!— a re-export of theinclude_dir!macro that bundles a directory tree into the binary at compile time. Gated on the defaultembedfeature.
HTTP serving (responding to GET /static/... with the right
content-type, cache headers, etc.) lives in kick-rs-http's
AssetsPlugin so this crate stays free of axum.
Manifest
use AssetManifest;
let m = load?
.with_url_prefix;
let url = m.resolve?;
// "/static/app.a1b2c3.js"
# Ok::
Two JSON shapes are accepted out of the box.
Flat — the lowest-common-denominator format:
Vite's full manifest — what vite build emits when
build.manifest = true. Use AssetManifest::from_vite_json(...):
We reduce each entry to its file field; resolve("src/main.js")
returns the hashed JS URL. CSS / imports / dynamic assets aren't
surfaced separately yet — coming in a follow-up.
Errors are KickError-typed: RK_C_IO (read failure), RK_C_PARSE
(bad JSON), RK_C_UNKNOWN_ASSET (key not in manifest, hint includes
the catalog).
Embedded assets (default-on)
use ;
static ASSETS: EmbeddedAssets = embed_assets!;
if let Some = ASSETS.get_file
Disable with default-features = false if you only need the
manifest loader without the proc-macro compile cost.
The embed_assets! macro emits paths through kick_rs_assets itself
(via proc-macro-crate resolution), so adopters need only
kick-rs-assets in their Cargo.toml — no include_dir or any
other vendored dep.
Install
[]
= "0.1.0"
# or via the umbrella crate with the `assets` feature:
= { = "0.1.0", = ["assets"] }
License
MIT — see the workspace root.