Volt.CSS.AssetURLRewriter (Volt v0.19.2)

Copy Markdown View Source

Parser-backed CSS asset URL rewriting for production builds.

Uses Vize/LightningCSS to collect parser-backed URL ranges, then patches the original source without round-tripping through the serialized CSS AST.

Summary

Functions

Rebase relative asset URLs before an imported stylesheet loses its source location.

Rewrite relative CSS asset URLs to hashed output URLs.

Rewrite relative CSS asset URLs to dev-server URLs without copying files.

Rewrite relative CSS asset URLs and return emitted asset filenames.

Types

rewrite_assets_result()

@type rewrite_assets_result() ::
  {:ok, %{code: String.t(), assets: [Volt.Builder.Asset.t()]}}
  | {:error, term()}

rewrite_result()

@type rewrite_result() :: {:ok, String.t()} | {:error, term()}

Functions

rebase(css, source_path, output_base)

Rebase relative asset URLs before an imported stylesheet loses its source location.

rewrite(css, source_path, outdir, opts \\ [])

@spec rewrite(String.t(), String.t() | nil, String.t(), keyword()) :: rewrite_result()

Rewrite relative CSS asset URLs to hashed output URLs.

rewrite_dev(css, source_path, root, prefix, opts \\ [])

Rewrite relative CSS asset URLs to dev-server URLs without copying files.

rewrite_with_assets(css, source_path, outdir, opts \\ [])

@spec rewrite_with_assets(String.t(), String.t() | nil, String.t(), keyword()) ::
  rewrite_assets_result()

Rewrite relative CSS asset URLs and return emitted asset filenames.