static_files/lib.rs
1#![doc(test(no_crate_inject))]
2/*!
3# static-files - the library to help automate static resource collection
4
5## Legal
6
7Dual-licensed under `MIT` or the [UNLICENSE](http://unlicense.org/).
8
9## Features
10
11- Embed static resources in executuble
12- Install dependencies with [npm](https://npmjs.org) package manager
13- Run custom `npm` run commands (such as [webpack](https://webpack.js.org/))
14- Support for npm-like package managers ([yarn](https://yarnpkg.com/))
15- Change detection support to reduce compilation time
16
17## Usage
18
19Create folder with static resources in your project (for example `static`):
20
21```bash
22cd project_dir
23mkdir static
24echo "Hello, world" > static/hello
25```
26
27Add to `Cargo.toml` dependency to `static-files`:
28
29```toml
30[dependencies]
31static-files = "0.2"
32
33[build-dependencies]
34static-files = "0.2"
35```
36
37Add `build.rs` with call to bundle resources:
38
39```rust#ignore
40use static_files::resource_dir;
41
42fn main() -> std::io::Result<()> {
43 resource_dir("./static").build()?;
44}
45```
46
47Include generated code in `main.rs`:
48
49```rust#ignore
50include!(concat!(env!("OUT_DIR"), "/generated.rs"));
51
52fn main() -> std::io::Result<()> {
53 let generated = generate(); // <-- this function is defined in generated.rs
54 ...
55}
56```
57*/
58
59mod mods;
60
61pub use mods::{
62 npm_build::{npm_resource_dir, NpmBuild},
63 resource::{self, Resource},
64 resource_dir::{resource_dir, ResourceDir},
65 sets,
66};