| Crates.io | static-files |
| lib.rs | static-files |
| version | 0.3.1 |
| created_at | 2021-03-18 20:18:19.46573+00 |
| updated_at | 2025-08-24 15:40:49.183824+00 |
| description | The library to help automate static resource collection. |
| homepage | https://github.com/static-files-rs/static-files |
| repository | https://github.com/static-files-rs/static-files |
| max_upload_size | |
| id | 370724 |
| size | 36,415 |
Dual-licensed under MIT or the UNLICENSE.
npm run commands (such as webpack)Create folder with static resources in your project (for example static):
cd project_dir
mkdir static
echo "Hello, world" > static/hello
Add to Cargo.toml dependency to static-files:
[dependencies]
static-files = "0.3"
[build-dependencies]
static-files = "0.3"
Add build.rs with call to bundle resources:
use static_files::resource_dir;
fn main() -> std::io::Result<()> {
resource_dir("./static").build()
}
Include generated code in main.rs:
include!(concat!(env!("OUT_DIR"), "/generated.rs"));
fn main() -> std::io::Result<()> {
let generated = generate(); // <-- this function is defined in generated.rs
// ...
Ok(())
}
By default, 'static-files' collects all files in operation system defined order, but you can change it by activating 'sort' feature in Cargo.toml:
[dependencies]
static-files = { version = "0.3", features = ["sort"] }
[build-dependencies]
static-files = { version = "0.3", features = ["sort"] }