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

#124 in Operating systems

Download history 2174/week @ 2024-07-17 2437/week @ 2024-07-24 2356/week @ 2024-07-31 2214/week @ 2024-08-07 1910/week @ 2024-08-14 2186/week @ 2024-08-21 2369/week @ 2024-08-28 2441/week @ 2024-09-04 2293/week @ 2024-09-11 2745/week @ 2024-09-18 2944/week @ 2024-09-25 2382/week @ 2024-10-02 2507/week @ 2024-10-09 2542/week @ 2024-10-16 2745/week @ 2024-10-23 2793/week @ 2024-10-30

10,885 downloads per month
Used in 26 crates (21 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