PhoenixAssets. Config
(PhoenixAssets v0.1.0)
View Source
Validated, normalized configuration for phoenix_assets.
Reads the host application's config :phoenix_assets, ... keys and returns a
t/0 struct. The top-level scalar keys are validated against a strict
NimbleOptions schema; the nested sub-configs (:dev, :build, :env,
:dev_intelligence, :stack) are captured as keyword lists for the subsystems
that own their validation (the dev supervisor, the generators, the doctor).
The :env sub-config (config :phoenix_assets, :env, expose: [...]) carries an
expose: allow-list of constants surfaced to the frontend; it is stored on the
:env_expose struct field and consumed by PhoenixAssets.Generators.Env.
The :dev_intelligence sub-config carries tidewave: true, the opt-in for
PhoenixAssets.DevIntelligence.TidewaveTools.
Example
config :phoenix_assets,
otp_app: :my_app,
endpoint: MyAppWeb.Endpoint,
router: MyAppWeb.Router,
preset: MyApp.Assets.Stack
iex> config = PhoenixAssets.Config.load!(otp_app: :my_app)
iex> config.asset_root
"assets"See also
PhoenixAssets.Context-- the per-run snapshot built from a config.
Summary
Functions
Loads and validates configuration.
Resolves the ordered {plugin, opts} list for a config.
The raw schema for the top-level scalar options, for documentation and tooling.
Types
@type t() :: %PhoenixAssets.Config{ asset_root: String.t(), build: keyword(), dev: keyword(), dev_intelligence: keyword(), endpoint: module() | nil, endpoint_prefixes: [String.t()], env_expose: keyword(), generated_dir: String.t(), js_runtime: :node | :bun, otp_app: atom(), package_manager: :pnpm | :npm | :bun, preset: module() | nil, router: module() | nil, serve_mode: :ssr | :spa, ssr_runtime: :node | :bun, stack: keyword(), static_assets_path: String.t(), static_root: String.t() }
Functions
Loads and validates configuration.
Without arguments, reads Application.get_all_env(:phoenix_assets). A keyword
list may be passed instead (primarily for tests). Raises NimbleOptions
validation errors for invalid scalar options.
Resolves the ordered {plugin, opts} list for a config.
When the host has not configured a :preset, the built-in default preset
PhoenixAssets.Presets.Svelte is used, so the full Svelte stack works without a
hand-written preset module. Set :preset to compose a different stack.
@spec schema() :: keyword()
The raw schema for the top-level scalar options, for documentation and tooling.