3个不稳定版本
0.2.0 | 2020年5月13日 |
---|---|
0.1.1 | 2020年5月13日 |
0.1.0 | 2020年5月13日 |
#1204 in HTTP服务器
11KB
194 行
包含NPM
将静态 npm build
输出包含在Rust二进制文件中
在调试模式下编译时,文件内容将从磁盘读取,而不是嵌入。这可以通过embed
特性手动覆盖。
const ASSETS: inpm::Dir = inpm::include_package!("./client/dist");
let content_of_my_file = ASSETS.get("some_dir/my_file.txt").contents();
Warp特性
特性=["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
:
包含NPM
将静态 npm build
输出包含在Rust二进制文件中 当你在调试模式下编译时,文件内容将从磁盘读取,而不是嵌入。这可以通过embed
特性手动覆盖。
参数路径是npm构建的输出目录。父目录是包含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特性
特性=["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");
依赖关系
~1–12MB
~147K SLoC