Dual-licensed under MIT
or the UNLICENSE.
npm
run commands (such as webpack)Create folder with static resources in your project (for example static
):
bash
cd project_dir
mkdir static
echo "Hello, world" > static/hello
Add to Cargo.toml
dependency to static-files
:
```toml [dependencies] static-files = "0.1"
[build-dependencies] static-files = "0.1" ```
Add build.rs
with call to bundle resources:
```rust#ignore use staticfiles::resourcedir;
fn main() -> std::io::Result<()> { resource_dir("./static").build()?; } ```
Include generated code in main.rs
:
```rust#ignore include!(concat!(env!("OUT_DIR"), "/generated.rs"));
fn main() -> std::io::Result<()> { let generated = generate(); // <-- this function is defined in generated.rs ... } ```