Struct includer_codegen::WebAssets[][src]

pub struct WebAssets { /* fields omitted */ }

Methods

impl WebAssets
[src]

Creates a new WebAssets Pipeline

By default the filter list type is a blacklist.

Add a filter to the pipeline

Filters are applied in the order that they were added, the first matching filter determines how the file entry is handled. If you want to include all javascript files, but not the ones in a certain folder, then you should add the exclusion rule first, and then the inclusion filter.

If there are no filters then all files are matched. If there are no filters and it's a whitelist, no files are matched.

Examples

Matching everything except css and json files:

WebAssets::new("NON_IMAGE_ASSETS", "../resources")
    .filter(Filter::exclude_extension("css"))
    .filter(Filter::exclude_extension("json"));

Include all javascript files, but exclude all in the adminsubdirectory:

WebAssets::new("ASSETS", "./web/dist")
    .whitelist()
    .filter(Filter::exclude_regex(r"^admin/.*$"))
    .filter(Filter::include_extension("js"));

If you wanted to only match text and markdown files:

WebAssets::new("ASSETS", "../notes")
    .whitelist()
    .filter(Filter::include_extension("txt"))
    .filter(Filter::include_extension("md"));

or to include all css files in a subdirectory styles:

WebAssets::new("ASSETS", "../web/dist")
    .whitelist()
    .filter(Filter::include_regex(r"^styles/.*\.css$"));

NOTE: If you need to care about multi-platform it's your responsibility to use a proper regex that accounts for the proper path separator. See FilterRule::regex for examples that account for this. AFAIK std::path doesn't normalize the separators.

Sets the prefix to use for the normalized path uri.

This is relative to where your asset path is. If your asset path is "./web/dist/assets", with your web root being at "./web/dist", then having a prefix of "/assets" would make the relative URIs align with your web root to make the hit URL correct.

Defaults to "/"

Sets the path to the assets directory.

Set the filter list type to a blacklist.

Set the filter list type to a whitelist.

Boxes up the pipeline to pass to Codegen easily.

Sets whether to include the brotli version of every file too

Sets whether to include the gzip version of every file too

Trait Implementations

impl Display for WebAssets
[src]

Formats the value using the given formatter. Read more

impl Pipeline for WebAssets
[src]

Auto Trait Implementations

impl Send for WebAssets

impl Sync for WebAssets