sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into the next-gen of Phoenix!
Trending in Guides/Tuts
# ~/src/livebook/.iex.exs
System.cmd("xdg-open", [ LivebookWeb.Endpoint.access_url() ] )
Because Livebook requires a unique passcode on ...
New
You probably already know that <span>{nil}</span> in a HEEX template produces <span> </span> when rendered. I fin...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
soyjeansoy
cvkmohan
How do we handle fonts using this build chain?
For example Inter | Fontsource - how do we add and use?
thomas.fortes
In your app.css you just import and use normally.
And then in your endpoint watcher config for esbuild in dev.exs you have to pass the loaders to the command.
You could also use dataurl instead of file and esbuild will embed the fonts encoded as base64 (not recommended, my css file went to more than 6MB with dataurls).
Edit: Sorry, didn’t read the entire post, they remove the css processing from esbuild and handle it with postcss, in this case what I would do is ignore the esbuild base config of phoenix, install it manually and use the api to load the esbuild postcss plugin (esbuild plugins aren’t available through the cli), but in this case you will have to make a tradeoff between simplicity (no need for node, npm or anything else in phoenix 1.6) and power.
outlog
not quite as easy as @thomas.fortes suggests..
but close if you are OK with a seperate css file for the font (face) and thus using esbuild for it..
Inter Webfolder into say /assets/vendor/fonts and rename the folder toInterWeb(need to avoid spaces!)~w(js/app.js vendor/fonts/InterWeb/inter.css --bundle --loader:.woff2=file --loader:.woff=file --target=es2016 --outdir=../priv/static/assets),go to your layout and change the js script src to
Routes.static_path(@conn, "/assets/js/app.js")<link phx-track-static rel="stylesheet" href="<%= Routes.static_path(@conn, "/assets/vendor/fonts/InterWeb/inter.css") %>"/>for bonus points:
add GitHub - semencov/tailwindcss-font-inter: TailwindCSS Plugin to integrate with Inter Typeface · GitHub by doing:
npm install --save-dev tailwindcss-font-inter(in the assets folder)and then add the plugin in the tailwind config:
now you can use the css class
font-interwherever you want..niccolox
will Tailwind be also default for Phoenix 1.6?
jeremyjh
No, in this article you can see he is installing it from NPM:
npm install autoprefixer postcss postcss-import postcss-cli tailwindcss --save-devmekusigjinn
woo nice! Quick question - how would I enable
scss?cvkmohan
Going with dart-sass npm package is one alternative. But, if you only need sass - GitHub - CargoSense/dart_sass: Install and run Dart Sass using Elixir. · GitHub is a very good alternative to consider.
thiagomajesk
Great job @sergio!
Now that Phoenix 1.6.0-rc.0 is out, I tried to migrate my app and this other post also provided me some insights: How I Handle Static Assets in my Phoenix apps | Mitchell Hanberg.
I ended up with something like this:
package.json
dev.exs
PS.: Even though there’s too much configuration for my taste still, the recompilations are fast, really really fast now with esbuild.
Update: BTW: It seems you don’t need to have postcss installed at all if you are using just Tailwind for your styles. You can replace the deploy script with:
NODE_ENV=production tailwindcss -i css/app.css -o ../priv/static/assets/app.css --minifytao
This guide was super helpful; thank you! I noticed that it doesn’t minify CSS. If you want that, it’s very easy to add if you’re already using PostCSS:
npm --prefix assets install --save-dev cssnanopostcss.config.js:esbuild also supports Typescript out of the box; just make sure to read the caveats if you’re going to use it.