vite-static 0.4.0

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

// To add vite static, we need to create struct and add `vite_static::Manifest` derive.
// `Manifest` derive macro has options, such as vite_dist.
// Look into documentation, if you want to see all options and descriptions for them.

#[derive(Manifest)]
// You can specify relative path (to Cargo.toml):
#[vite_dist = "examples/vite-project/dist"]
// Or you can specify absolute path:
// #[vite_dist = "/absolute/path/to/dist"]
// Or you can use environment variables to specify path:
// #[vite_dist = "env:MY_VITE_STATIC_PATH|/default/path/to/dist"]
struct MyViteStatic;

// Now we are ready to use `MyViteStatic` struct!

fn main() {
    // You can:

    // - Query all chunks (files)
    let chunks = MyViteStatic.manifest_chunks();
    dbg!(chunks);

    // - Resolve manifest key into output filename
    //   Manifest key - is pretty name from `src/` folder (f.e. main.ts)
    //   Output filename - is processed file from `dist/` folder (f.e. main.SOMEHASH.js)
    let entry1_filename = MyViteStatic
        .resolve_output("src/entry1.js") // returns Option<&str>
        .expect("failed to find src/entry1.js file"); // so this is optional
    println!("src/entry1.js -> {entry1_filename}");

    // - Get chunk by output filename
    let entry1 = MyViteStatic
        .chunk(entry1_filename)
        .expect("failed to get src/entry1.js chunk");
    assert_eq!(entry1.file, entry1_filename);

    // By using `Manifest` trait, you can implement integration to _any_ framework
    // And of course, vite-static has some builtin integrations, that you can enable with feature flags
}