| Crates.io | static_bundler |
| lib.rs | static_bundler |
| version | 0.1.1 |
| created_at | 2025-02-27 23:51:52.143967+00 |
| updated_at | 2025-03-05 00:57:53.385754+00 |
| description | A tool to bundle files into a JSON blob with each key representing a file path and the value being the file content. |
| homepage | |
| repository | https://github.com/ericrobolson/static_bundler |
| max_upload_size | |
| id | 1572303 |
| size | 10,692 |
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.
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);