Struct static_files::NpmBuild[][src]

pub struct NpmBuild { /* fields omitted */ }
Expand description

Executes npm commands before collecting resources.

Example usage: Add build.rs with call to bundle resources:

use 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:

include!(concat!(env!("OUT_DIR"), "/generated.rs"));

Implementations

Allow the user to set their own npm-like executable (like yarn, for instance)

Generates change detection instructions.

It includes package.json directory, ignores by default node_modules, package.json and package-lock.json and target directory. Each time npm changes timestamps on these files, so if we do not ignore them - it runs npm each time. It is recommended to put your dist files one level deeper. For example, if you have web with package.json and dist just below that, you better generate you index.html somewhere in web\dist\sub_path\index.html. Reason is the same, npm touches dist each time and it touches the parent directory which in its turn triggers the build each time. For complete example see: Angular Router Sample. If default behavior does not work for you, you can use change-detection directly.

Executes npm install.

Executes npm run CMD.

Sets target (default is node_modules).

Sets stderr for the next command.

You should set it again, if you need also redirect output for the next command.

Sets stdout for the next command.

You should set it again, if you need also redirect output for the next command.

Converts to ResourceDir.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.