10 releases

0.3.1 Aug 24, 2025
0.3.0 Aug 20, 2025
0.2.5 Jun 12, 2025
0.2.4 Jul 9, 2024
0.0.1 Mar 18, 2021

#132 in Data structures

Download history 7373/week @ 2025-10-11 6793/week @ 2025-10-18 7942/week @ 2025-10-25 8538/week @ 2025-11-01 5283/week @ 2025-11-08 6762/week @ 2025-11-15 11015/week @ 2025-11-22 10409/week @ 2025-11-29 8516/week @ 2025-12-06 9838/week @ 2025-12-13 7491/week @ 2025-12-20 8468/week @ 2025-12-27 11757/week @ 2026-01-03 10602/week @ 2026-01-10 11242/week @ 2026-01-17 14821/week @ 2026-01-24

50,588 downloads per month
Used in 25 crates (20 directly)

Unlicense OR MIT

32KB
611 lines

static-files - the library to help automate static resource collection

Dual-licensed under MIT or the UNLICENSE.

Features

  • Embed static resources in executuble
  • Install dependencies with npm package manager
  • Run custom npm run commands (such as webpack)
  • Support for npm-like package managers (yarn)
  • Change detection support to reduce compilation time

Usage

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"] }

Dependencies

~290KB