swc_core::base::sourcemap

Function make_relative_path

pub fn make_relative_path(base: &str, target: &str) -> String
Available on crate feature __base only.
Expand description

Helper function to calculate the path from a base file to a target file.

This is intended to caculate the path from a minified JavaScript file to a sourcemap if they are both on the same server.

Example:

assert_eq!(&make_relative_path(
    "/foo/bar/baz.js", "/foo/baz.map"), "../baz.map");