3 unstable releases

0.2.0 May 13, 2020
0.1.1 May 13, 2020
0.1.0 May 13, 2020

#1203 in HTTP server

MIT license

11KB
194 lines

Inlucde NPM

Include Static npm build ouput in your rust binary

When you compile in debug mode the File contents will just be read from disk and not embedded. This can manually be overriden with the embed feautere.

const ASSETS: inpm::Dir = inpm::include_package!("./client/dist");


let content_of_my_file = ASSETS.get("some_dir/my_file.txt").contents();

Warp feature

features=["warp"]

const ASSETS: inpm::Dir = inpm::include_package!("./client/dist");


let my_file_filter = inpm::warp::embedded(ASSETS);

// Allso works with single page applications

let my_spa_filter = inpm::warp::spa(ASSETS, "index.html");



lib.rs:

Inlucde NPM

Include Static npm build ouput in your rust binary When you compile in debug mode the File contents will just be read from disk and not embedded. This can manually be overriden with the embed feautere.

The argument path is the ouput directory of the npm build. The parent directory is the directory with package.json

const ASSETS: inpm::Dir = inpm::include_package!("./client/dist");


let content_of_my_file = ASSETS.get("some_dir/my_file.txt").unwrap().contents();

Warp feature

features=["warp"]

const ASSETS: inpm::Dir = inpm::include_package!("./client/dist");


let my_file_filter = inpm::warp::embedded(ASSETS);

// Allso works with single page applications

let my_spa_filter = inpm::warp::spa(ASSETS, "index.html");


Dependencies

~1–12MB
~150K SLoC