static_bundler

Crates.iostatic_bundler
lib.rsstatic_bundler
version0.1.1
created_at2025-02-27 23:51:52.143967+00
updated_at2025-03-05 00:57:53.385754+00
descriptionA tool to bundle files into a JSON blob with each key representing a file path and the value being the file content.
homepage
repositoryhttps://github.com/ericrobolson/static_bundler
max_upload_size
id1572303
size10,692
Eric Olson (ericrobolson)

documentation

https://docs.rs/static_bundler/latest/static_bundler/

README

static_bundler

A tool to bundle files into a JSON blob with each key representing a file path and the value being the file content.

An example use case is a HTTP server that needs to serve HTML pages.

Example Usage

Add to cargo:

[build-dependencies]
static_bundler = "0.1.0"

Add to build.rs:

fn main() {
    println!("Building webview static files");
    const SRC_DIR: &str = "static/";
    const DEST_FILE: &str = ".static_files.json";

    let json_string = static_bundler::compile_static_files(SRC_DIR);

    std::fs::write(DEST_FILE, json_string).unwrap();
}

Add to your code:

let json_blob = include_str!("../.static_files.json");
let files = static_bundler::decode_static_files(json_blob);
Commit count: 3

cargo fmt