6 releases

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

#1033 in Data structures

Download history 2620/week @ 2023-11-23 2867/week @ 2023-11-30 2327/week @ 2023-12-07 2371/week @ 2023-12-14 2347/week @ 2023-12-21 2286/week @ 2023-12-28 2381/week @ 2024-01-04 2539/week @ 2024-01-11 2614/week @ 2024-01-18 2524/week @ 2024-01-25 2318/week @ 2024-02-01 2372/week @ 2024-02-08 2539/week @ 2024-02-15 2191/week @ 2024-02-22 2288/week @ 2024-02-29 1726/week @ 2024-03-07

9,179 downloads per month
Used in 23 crates (18 directly)

Unlicense OR MIT

27KB
490 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