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

#941 in Data structures

Download history 2761/week @ 2023-12-18 2174/week @ 2023-12-25 2147/week @ 2024-01-01 2557/week @ 2024-01-08 2551/week @ 2024-01-15 2642/week @ 2024-01-22 2440/week @ 2024-01-29 2201/week @ 2024-02-05 2632/week @ 2024-02-12 2255/week @ 2024-02-19 2154/week @ 2024-02-26 2299/week @ 2024-03-04 2653/week @ 2024-03-11 3141/week @ 2024-03-18 3116/week @ 2024-03-25 3012/week @ 2024-04-01

12,198 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