Volt.CSS.AssetURLRewriter (Volt v0.14.6)

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

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: [String.t() | map()]}} | {:error, term()}

rewrite_result()

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

Functions

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)

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

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.