Volt.Config (Volt v0.9.0)

Copy Markdown View Source

Read Volt configuration from application environment.

All config lives under the :volt application key in config/config.exs:

# config/config.exs
config :volt,
  entry: "assets/js/app.ts",
  target: :es2020,
  external: ~w(phoenix phoenix_html phoenix_live_view),
  aliases: %{
    "@" => "assets/src",
    "@components" => "assets/src/components"
  },
  plugins: [],
  tailwind: [
    css: "assets/css/app.css",
    sources: [
      %{base: "lib/", pattern: "**/*.{ex,heex}"},
      %{base: "assets/", pattern: "**/*.{vue,ts,tsx}"}
    ]
  ]

# config/dev.exs
config :volt, :server,
  prefix: "/assets",
  watch_dirs: ["lib/"]

CLI flags and plug options override config values.

Source maps

The :sourcemap option controls production source map generation:

  • true — write .map files and append //# sourceMappingURL (default)
  • :hidden — write .map files but omit the URL comment (for error tracking services)
  • false — no source maps

Manual chunks

The :chunks option controls manual chunk splitting:

config :volt,
  chunks: %{
    "vendor" => ["vue", "vue-router", "pinia"],
    "ui" => ["assets/src/components"]
  }

Bare specifiers match package names in node_modules. Path patterns match against the full module path.

tsconfig.json paths

Volt automatically reads compilerOptions.paths from tsconfig.json in the project root and merges them into aliases. Explicitly configured aliases take precedence over tsconfig paths.

Summary

Functions

Read the full build config, merged with defaults.

Read dev server config, merged with defaults.

Read Tailwind config.

Functions

build(overrides \\ [])

@spec build(keyword()) :: map()

Read the full build config, merged with defaults.

overrides (from CLI flags or function opts) take precedence over app env, which takes precedence over defaults.

Automatically reads compilerOptions.paths from tsconfig.json and merges them into aliases. Explicit aliases override tsconfig paths.

server(overrides \\ [])

@spec server(keyword()) :: map()

Read dev server config, merged with defaults.

tailwind()

@spec tailwind() :: keyword()

Read Tailwind config.