PhoenixAssets.Graph.Compiled (PhoenixAssets v0.1.0)

View Source

Embeds the asset graph in a module for in-memory runtime lookups.

use PhoenixAssets.Graph.Compiled, graph: path reads graph.json at compile time, embeds it, and defines graph/0, entry!/1, page!/1, and route!/1. The graph file is registered as an @external_resource, so the module recompiles when it changes.

Example

defmodule MyAppWeb.Generated.Assets do
  use PhoenixAssets.Graph.Compiled,
    graph: "priv/phoenix_assets/graph.json"
end

MyAppWeb.Generated.Assets.route!("device_show")

use PhoenixAssets.Graph.Compiled

Using this module reads the configured graph file at compile time, registers it as an external resource, and defines graph/0, entry!/1, page!/1, and route!/1.