Crate static_files[][src]

Expand description

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

Dual-licensed under MIT or the UNLICENSE.


  • 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


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:

static-files = "0.2"

static-files = "0.2"

Add with call to bundle resources:

use static_files::resource_dir;

fn main() -> std::io::Result<()> {

Include generated code in

include!(concat!(env!("OUT_DIR"), "/"));

fn main() -> std::io::Result<()> {
    let generated = generate(); // <-- this function is defined in


Resource definition and single module based generation.

Support for module based generations. Use it for large data sets (more than 128 Mb).


Executes npm commands before collecting resources.

Static files resource.

Resource dir.


Generate resources with run of npm install prior to collecting resources in resource_dir.

Generate resources for resource_dir.