PhoenixAssets.ManifestServer (PhoenixAssets v0.1.0)

View Source

Holds the parsed Vite manifest for fast, lock-free reads.

In production the manifest is static, so it is parsed once at boot and stored in :persistent_term for zero-copy concurrent reads. In development the build output is constantly changing, so manifest/0 returns the :dev sentinel and callers (the components) emit Vite dev-server URLs instead of hashed files.

Summary

Functions

Returns a specification to start this module under a supervisor.

Returns the parsed manifest, the :dev sentinel in development, or {:error, :missing} when no manifest is available.

Re-reads the manifest from disk and refreshes the cache.

Starts the manifest server.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

manifest()

@spec manifest() :: PhoenixAssets.Manifest.t() | :dev | {:error, :missing}

Returns the parsed manifest, the :dev sentinel in development, or {:error, :missing} when no manifest is available.

reload()

@spec reload() :: :ok

Re-reads the manifest from disk and refreshes the cache.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Starts the manifest server.

Options:

  • :path -- the manifest.json location. When absent or unreadable, reads resolve to {:error, :missing}.

This is a singleton registered under the module name; the cache lives in a single :persistent_term key, so only one instance runs per node.