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:
parent
bb2a88fb15
commit
1b031ecdc3
2 changed files with 35 additions and 1 deletions
14
.gitignore
vendored
14
.gitignore
vendored
|
|
@ -26,6 +26,20 @@
|
||||||
/agent/burrito_out/
|
/agent/burrito_out/
|
||||||
/agent/dist/
|
/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
|
# Editors / OS
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,30 @@ defmodule Server.MixProject do
|
||||||
elixirc_paths: elixirc_paths(Mix.env()),
|
elixirc_paths: elixirc_paths(Mix.env()),
|
||||||
start_permanent: Mix.env() == :prod,
|
start_permanent: Mix.env() == :prod,
|
||||||
aliases: aliases(),
|
aliases: aliases(),
|
||||||
deps: deps()
|
deps: deps(),
|
||||||
|
releases: releases()
|
||||||
]
|
]
|
||||||
end
|
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.
|
# Configuration for the OTP application.
|
||||||
#
|
#
|
||||||
# Type `mix help compile.app` for more information.
|
# Type `mix help compile.app` for more information.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue