vite-static 0.5.0

Embed Vite chunks into your Rust application and query them individually.
Documentation
use vite_static::Manifest;

// #[no_embedding] - is an option, that allows you to generate trait implementation, that parses and
// loads chunks on runtime (no chunk and manifest embedding).
//
// This can speed up builds, but it's recommended to embed in release builds.
//
// Note, that:
//  - Manifest is lazy loaded and affter first read never re-read (except if you restart your app).
//  - It does not implement `StaticManifest` (duh), so there's no method to query all chunks at the
//  same time. (Only `Manifest` trait, that should be enough for 99.8% situations).
//  - Chunks are re-read, hash re-computed and mime type is guessed on every function call (chunk,
//  chunk_by_key).

#[derive(Manifest)]
#[vite_dist = "examples/vite-project/dist"]
#[cfg_attr(debug_assertions, no_embedding)] // RECOMMENDED!
// ^- this will add `#[no_embedding]` only on debug builds!
// It's very hard for some reason to detect release and debug builds inside proc-macro
// so you can choose when to embed. Win for everybody.
//
// or you can enable no embedding for every build:
// #[no_embedding]
struct MyViteStatic;

fn main() {
    let entry1 = MyViteStatic.chunk_by_key("src/entry1.js");
    dbg!(entry1);
}

// To see difference:
//
// ```shell
// cargo expand --example dynamic           # debug build (no chunks embedded)
// cargo expand --example dynamic --release # release build (chunks are embedded)
// ```