Volt.PublicDir (Volt v0.13.1)

Copy Markdown View Source

Optional Vite-style public directory support.

Phoenix apps normally serve stable public files from priv/static through Plug.Static, so this feature is disabled by default. When enabled for Vite compatibility, files in the configured public directory are served from the site root in development and copied as-is to the production static root. They are not transformed, hashed, or included in the module graph, so application code should reference them with root-absolute URLs such as /favicon.svg.

Summary

Functions

Copies all files from public_dir into static_root.

Resolves a root-relative request path inside public_dir.

Returns the expanded public directory path, or nil when disabled.

Functions

copy(public_dir, static_root)

@spec copy(String.t() | nil, String.t()) :: :ok

Copies all files from public_dir into static_root.

Missing public directories are ignored. Existing files at the destination are overwritten, matching the usual behavior of build output generation.

lookup(public_dir, request_path)

@spec lookup(String.t() | nil, String.t()) :: String.t() | nil

Resolves a root-relative request path inside public_dir.

Returns nil for missing files, directories, disabled public directories, or paths that would escape the public directory.

resolve(path)

@spec resolve(String.t() | false | nil) :: String.t() | nil

Returns the expanded public directory path, or nil when disabled.