Phoenix 1.6.0 LiveView + esbuild + Tailwind JIT + AlpineJS - A brief tutorial

This was a really great guide thank you! I also had to cross-reference the asset management guide:

That I found after this forum post on external flags for esbuild. You’ll notice that the asset_management guide is updated to reflect external: rather than external=. I also cross-referenced with PragProg’s free guide on Tailwind with esbuild, particularly they add slightly to the deploy script in the assets/package.json:

"scripts": {
  "deploy": "NODE_ENV=production tailwindcss --postcss --minify --input=css/app.css --output=../priv/static/assets/app.css"
},

Finally, I had to make slight adjustments because Metamorphic has an umbrella app structure. So, my base project mix.exs has this:

"assets.deploy": [
  "cmd --cd ../metamorphic_web/assets npm run deploy",
  "esbuild default --minify",
  "phx.digest"
]

And my esbuild config expands the path as such:

cd: Path.expand("../apps/metamorphic_web/assets", __DIR__)

That did the trick for me along with making sure my asset handling with priv/static was updated for deployment following the upgrade from a 1.5 app to 1.6.

So, if anyone else is working in an umbrella app, then hopefully this helps you out too. And, again, thank you for the wonderful guide. :heart:

2 Likes