vite-static 1.1.1

Embed Vite chunks into your Rust application and query them individually.
Documentation
//! Example with `base` option.
//!
//! ```shell
//! cargo run --example options-base
//! ```

// Most of the time you change location of your static assets.
//
// For this example, we'll add `/assets` base (AKA path prefix).
//
// 1. First things first, change base in the vite project.
//
//    Go to your vite project, `vite.config.js` and add `base` option:
//
//    ```diff
//     // <snip>
//     export default defineConfig({
//    +    base: "/assets",
//         build: {
//             manifest: true,
//             // <snip>
//         }
//     })
//    ```
//
//    Now, all rendered paths will have `/assets` base.
//
// ...continued below

use vite_static::Manifest;

#[derive(Manifest)]
#[vite_dist = "examples/vite-project/dist"]
// ...
// 2. Modify the macro, by adding `#[base = "..."]` option:
#[base = "/static"]
// NOTE: this is same as `#[base = "/static/"]` and `#[base = "assets"]`
struct MyViteStatic;

// Done!
//
// This example only shows, how to add this option.
// When you use manifest as usual, you will see that output paths (`ManifestChunk.file`) are not prefixed with base.
//
// So the fix is to prefix manually in integrations.
//
// `HtmlIntegration` prefixes all paths with `base` and `ActixFiles` service uses `base`
// as root path.

fn main() {
    println!("{}", MyViteStatic.base()); // get base path
}