vite-static 1.1.1

Embed Vite chunks into your Rust application and query them individually.
Documentation
use std::sync::LazyLock;

use vite_static::{HtmlIntegration, Manifest};

#[derive(Manifest)]
#[vite_dist = "examples/vite-project/dist"]
#[base = "/static"] // this is the base, used in `vite-project/`. Learn more in `options/base.rs`.
struct MyViteStatic;

// NOTE: HtmlIntegration takes into account `base` path!

// Usage examples:

fn usage1() {
    // Just call whenever you need HTML
    let html = HtmlIntegration::new(MyViteStatic.boxed())
        // import chunks, that you need
        .import("src/entry1.js")
        .import("src/entry2.js")
        // and get html with stylesheets, preloads of dependencies and script tags:
        .build();

    eprintln!("html:\n{html}");
}

// OR

// Create lazy global variable
static HTML: LazyLock<HtmlIntegration> = LazyLock::new(|| {
    // with default HTML (e.g. with shared scripts, libraries)
    HtmlIntegration::new(MyViteStatic.boxed()).import("src/entry1.js")
});

fn usage2() {
    // And clone it whenever you need it.
    let _html1 = HTML.clone().build();
    let _html2 = HTML.clone().import("src/entry2.js").build();
}

fn main() {
    usage1();
    usage2();
}