Skip to main content

relativize_asset_paths

Function relativize_asset_paths 

Source
pub fn relativize_asset_paths(
    el: &mut Element,
    root: &Path,
    outside: &mut Vec<String>,
)
Expand description

Rewrite every <image src> under el that points inside root to a path relative to it, recording in outside the ones that point elsewhere.

The inverse of the compiler’s asset resolution, which makes every src absolute against the app directory on the machine that compiles. That is the right answer for running the app in place and the wrong one for an artifact that travels, so anything shipping an IR elsewhere (a packaged folder, a web build) puts the paths back first.

Rewritten paths are joined with forward slashes whatever the compiling machine uses: every platform’s loader accepts them, so an artifact built for another platform names its files in a way that platform can follow.