7 releases

0.2.4 Jul 9, 2024
0.2.3 Jul 5, 2021
0.2.2 Apr 29, 2021
0.1.0 Mar 20, 2021
0.0.1 Mar 18, 2021

#129 in Operating systems

Download history 2838/week @ 2024-10-26 3100/week @ 2024-11-02 2409/week @ 2024-11-09 2717/week @ 2024-11-16 2927/week @ 2024-11-23 2892/week @ 2024-11-30 2888/week @ 2024-12-07 2656/week @ 2024-12-14 1929/week @ 2024-12-21 2143/week @ 2024-12-28 3585/week @ 2025-01-04 3997/week @ 2025-01-11 3873/week @ 2025-01-18 4639/week @ 2025-01-25 4049/week @ 2025-02-01 3783/week @ 2025-02-08

17,121 downloads per month
Used in 27 crates (22 directly)

Unlicense OR MIT

27KB
492 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.2"

[build-dependencies]
static-files = "0.2"

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
    ...
}

Dependencies

~290KB