From 1b031ecdc35b63c4a90d485597988268c0a17c85 Mon Sep 17 00:00:00 2001 From: Carsten Date: Wed, 22 Apr 2026 10:18:28 +0200 Subject: [PATCH] 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. --- .gitignore | 14 ++++++++++++++ server/mix.exs | 22 +++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7566971..874ea44 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,20 @@ /agent/burrito_out/ /agent/dist/ +# Phoenix digest artifacts (built into release; shouldn't be committed) +/server/priv/static/assets/ +/server/priv/static/cache_manifest.json +/server/priv/static/*-*.ico +/server/priv/static/*-*.txt +/server/priv/static/*-*.txt.gz +/server/priv/static/*.gz +/server/priv/static/images/*-* +/server/priv/static/images/*.gz + +# Playwright / screenshots (local verification artifacts) +/.playwright-mcp/ +/*.png + # Editors / OS .DS_Store .vscode/ diff --git a/server/mix.exs b/server/mix.exs index 4acdd08..0e0048f 100644 --- a/server/mix.exs +++ b/server/mix.exs @@ -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.