fix(server): run assets.deploy as a mix release step

Without this, 'mix release' produced a tarball that had app.css/app.js
(so LiveView worked) but was missing cache_manifest.json and the digested
asset paths. Phoenix served the bare files OK, but the client-side
LiveView bootstrap timing was fragile: if a form was submitted before
the LiveSocket attached, the browser fell back to a native HTML GET,
producing bug-report URLs like /admin/hosts?host%5Bname%5D=repl.

Define a project releases/0 with a pre-assemble step that runs
assets.deploy, so minified + digested assets are baked into every
release tarball.

Also gitignore digested priv/static artifacts so dev-time byproducts
don't pollute commits.
This commit is contained in:
Carsten 2026-04-22 10:18:28 +02:00
parent bb2a88fb15
commit 1b031ecdc3
2 changed files with 35 additions and 1 deletions

View file

@ -9,10 +9,30 @@ defmodule Server.MixProject do
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
aliases: aliases(),
deps: deps()
deps: deps(),
releases: releases()
]
end
defp releases do
[
server: [
# Ensure JS/CSS are built, minified and digested before assembling the
# release. Without this step, priv/static/assets/cache_manifest.json is
# missing from the tarball — the browser still gets app.js (LiveView
# works) but phx-track-static cache-busting is broken and any form
# submitted during a dead-link window falls through to a native HTML
# GET.
steps: [&build_assets/1, :assemble]
]
]
end
defp build_assets(release) do
Mix.Task.run("assets.deploy")
release
end
# Configuration for the OTP application.
#
# Type `mix help compile.app` for more information.