Juneum
Elixir, Phoenix, and Javascript

Asset handling in Phoenix 1.6

August 30, 2021
trisager

At the time of writing this, Phoenix 1.6 RC 0 has been released. Among other things it introduces a new templating engine, new generators, and it replaces Webpack with Esbuild as the default asset building tool.

Esbuild is lightning fast compared to Webpack, something you discover almost immediately when you start working with Phoenix 1.6. However, it also does less than Webpack, since it only handles JavaScript and CSS. Other static assets such as images are not handled.

What this means in pratice is, you can no longer put favicons, images etc in the assets/static folder and expect them to be moved to priv/static as part of the build process. You will have to do that yourself, e.g. if you have been used to keeping images in assets/static/images, with Phoenix 1.6 you should keep them in priv/static/images instead.

If you are upgrading from 1.5 to 1.6 you should also update your .gitignore to only exclude priv/static/assets (where Esbuild stores CSS and JavaScript) instead of excluding the entire priv/static folder as you would with Phoenix 1.5.

← Back to articles