Phoenix + esbuild + Tailwind - cache busting

Hi,
I’m using Phoenix with esbuild and tailwind and I’m trying to set up cache busting with hashed files for CSS and JS files similar to this;

style-fd7ad3506f4e06af64a2a0bd1908b67b.css
bundle-45e270d7e26bbdf926188c96a787edc4.js

I only have one CSS and one JS file. I’ve been trying to set it up for the last couple of hours with no luck. Has anyone done this successfully?

The digest suffix is generated by mix phx.digest based on the content of files bundled by the esbuild and tailwind mix tasks…

There is nothing the be done; It just works ™️

3 Likes

You do not need to use esbuild and tailwind create hash.
Just do:

mix phx.digest 
1 Like

Is there more documentation on the Phoenix cache busting strategy? I got the files with hashed names, but Phoenix (1.7.6, MIX_ENV=dev) delivers the raw filenames.

For example

<link rel="icon" type="image/x-icon" href={~p"/favicon.ico"} />

becomes

<link rel="icon" type="image/x-icon" href="/favicon.ico">