Skip to content

Version CSS and JS URLs in production builds - #3

Merged
karim-semmoud merged 1 commit into
mainfrom
fix/asset-versioning
Oct 7, 2026
Merged

karim-semmoud merged 1 commit into
mainfrom
fix/asset-versioning

Conversation

@karim-semmoud

Copy link
Copy Markdown
Member

Summary

After a deploy, the live site kept serving the previous site.css until a hard refresh. GitHub Pages caches assets, and the CSS and JS URLs never changed between builds.

  • Add Soonex.Public.asset/1, which appends ?v=<version> when :asset_version is configured.
  • config/prod.exs sets the version to the first 12 characters of GITHUB_SHA (provided by GitHub Actions), or the build time in seconds outside Actions.
  • The root layout loads site.css and site.js through asset/1. Dev and test stay unversioned.
  • esbuild's split chunks are already content-hashed, so only the entry files need the query string.
  • Bump to 0.3.1 with a CHANGELOG entry.

Test plan

  • Under prod config, asset("/css/site.css") returns /soonex/css/site.css?v=<timestamp>, and with GITHUB_SHA set it returns ?v=<sha>.
  • In dev, asset("/css/site.css") returns /css/site.css.
  • mix compile --warnings-as-errors and mix credo --strict are clean.

Co-authored-by: Cursor <cursoragent@cursor.com>
@karim-semmoud
karim-semmoud merged commit 508a126 into main Oct 7, 2026
3 checks passed
@karim-semmoud karim-semmoud self-assigned this Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant