[−][src]Struct actix_web_static_files::NpmBuild
Executes npm
commands before collecting resources.
Example usage:
Add build.rs
with call to bundle resources:
ⓘThis example is not tested
use actix_web_static_files::NpmBuild; fn main() { NpmBuild::new("./web") .install().unwrap() // runs npm install .run("build").unwrap() // runs npm run build .target("./web/dist") .to_resource_dir() .build().unwrap(); }
Include generated code in main.rs
:
ⓘThis example is not tested
use actix_web::{App, HttpServer}; use actix_web_static_files; use std::collections::HashMap; include!(concat!(env!("OUT_DIR"), "/generated.rs")); #[actix_rt::main] async fn main() -> std::io::Result<()> { HttpServer::new(move || { let generated = generate(); App::new().service(actix_web_static_files::ResourceFiles::new( "/", generated, )) }) .bind("127.0.0.1:8080")? .run() .await }
Implementations
impl NpmBuild
[src]
pub fn new<P: AsRef<Path>>(package_json_dir: P) -> Self
[src]
pub fn executable(self, executable: &str) -> Self
[src]
Allow the user to set their own npm-like executable (like yarn, for instance)
pub fn install(self) -> Result<Self>
[src]
Executes npm install
.
pub fn run(self, cmd: &str) -> Result<Self>
[src]
Executes npm run CMD
.
pub fn target<P: AsRef<Path>>(self, target_dir: P) -> Self
[src]
Sets target (default is node_modules).
pub fn to_resource_dir(self) -> ResourceDir
[src]
Converts to ResourceDir
.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for NpmBuild
impl Send for NpmBuild
impl Sync for NpmBuild
impl Unpin for NpmBuild
impl UnwindSafe for NpmBuild
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,