PhoenixAssets. Graph
(PhoenixAssets v0.1.0)
View Source
The Phoenix Asset Graph: one artifact linking Phoenix concepts to build output.
The graph answers cross-cutting questions a single tool cannot: which route maps
to which page, which Vite entry loads it, which stylesheet and preloads it
needs, which Storybook story covers it, which Electric shape and PubSub topic it
depends on, which locale bundle it requires. It is assembled from the Vite
manifest (build output) plus the graph_entries/2 every plugin contributes,
and written to a JSON file consumed by tooling, the doctor, and the optional
compiled lookup module.
See also
PhoenixAssets.Graph.Builder-- assembles the graph map.PhoenixAssets.Graph.Compiled-- embeds it in a lookup module.
Summary
Functions
Builds the asset-graph map. See PhoenixAssets.Graph.Builder.build/2 for options.
The on-disk path of the asset graph for this context.
Loads the asset graph from its JSON file.
Builds and writes the asset graph to its JSON file, returning the path.
Functions
@spec build( PhoenixAssets.Context.t(), keyword() ) :: map()
Builds the asset-graph map. See PhoenixAssets.Graph.Builder.build/2 for options.
@spec graph_path(PhoenixAssets.Context.t()) :: Path.t()
The on-disk path of the asset graph for this context.
Defaults to priv/phoenix_assets/graph.json (relative to the project root);
override with config :phoenix_assets, :build, asset_graph: path. The
default lives outside priv/static so the graph is packaged with releases
without being publicly served.
@spec load(PhoenixAssets.Context.t()) :: {:ok, map()} | {:error, term()}
Loads the asset graph from its JSON file.
@spec write( PhoenixAssets.Context.t(), keyword() ) :: {:ok, Path.t()}
Builds and writes the asset graph to its JSON file, returning the path.
Output is canonical (PhoenixAssets.CanonicalJSON) and the write is atomic
(temp file + rename), so a concurrent reader never observes a partial graph
and identical input always produces identical bytes.