wwaldner
I followed this guide to setup Tailwind on a new phoenix application. Install Tailwind CSS with Phoenix - Tailwind CSS
In dev, any changes to my index.html.heex file automatically builds a new app.css, just like I would expect. However, any classes specified in the heex file are not being processed by tailwind, hence the styles do not work. How do I go about troubleshooting this? It is as if it can’t find, or is not looking for the classes in the heex file, yet the tailwind.config.js is setup to process the heex templates.
tailwind.config.js
let plugin = require('tailwindcss/plugin')
module.exports = {
content: [
'./js/**/*.js',
'../lib/*_web.ex',
'../lib/*_web/**/*.*ex'
],
theme: {
extend: {},
},
plugins: [
require('@tailwindcss/forms'),
plugin(({addVariant}) => addVariant('phx-no-feedback', ['&.phx-no-feedback', '.phx-no-feedback &'])),
plugin(({addVariant}) => addVariant('phx-click-loading', ['&.phx-click-loading', '.phx-click-loading &'])),
plugin(({addVariant}) => addVariant('phx-submit-loading', ['&.phx-submit-loading', '.phx-submit-loading &'])),
plugin(({addVariant}) => addVariant('phx-change-loading', ['&.phx-change-loading', '.phx-change-loading &']))
]
}
index.html.heex
<h1 class="text-3xl font-bold underline bg-orange-200">
Hello world!
</h1>
config.exs
config :tailwind,
version: "3.2.1",
default: [
args: ~w(
--config=tailwind.config.js
--input=css/app.css
--output=../priv/static/assets/app.css
),
cd: Path.expand("../assets", __DIR__)
]
dev.exs
...
watchers: [
# Start the esbuild watcher by calling Esbuild.install_and_run(:default, args)
esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]},
tailwind: {Tailwind, :install_and_run, [:default, ~w(--watch)]}
]
...
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
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)
tcoopman
Your tailwind config should probably also accept
*.heexSebb
this line does (should) do that.
Maybe there are templates in folders that do not match this glob, maybe
_webpart missing in the path or a file directly belowxxx_web.For example these template would not be processed by the tailwind compiler.
lib/templates/my-template-tailwind-does-not-see.heexlib/web/templates/my-other-template-tailwind-does-not-see.heexlib/my_web/my-other-other-template-tailwind-does-not-see.heextcoopman
Didn’t spot the
*before the ex on the last linewwaldner
Indeed this is strange. I can run
mix tailwind defaultand it processes the css classes as you would expect. It seems like it is not correctly triggered when a change to the files is detected. My page is reloading when I make a change to the HTML. The browser reloads and the updated HTML is shown, just not the css gubins. Running themix tailwind defaultmanually does make the classes available in the app.css.tcoopman
Can you verify that the watcher is actually running?
wwaldner
Not sure how to verify that…except that I do know that live-reload happens.
TunkShif
tailwindcss cli watch mode is not working properly in the latest version, so any file changes won’t trigger a css rebuild, see this issue: CLI watch mode not working correctly when using visual studio · Issue #9667 · tailwindlabs/tailwindcss · GitHub
The current workaround is to switch back to version 3.1.8.
arrowsmith
Did anyone figure out a fix for this? I’m experiencing the same problem and it’s driving me nuts - the tailwind watcher isn’t detecting changes to my app code, so my app.css doesn’t get rebuilt. I have to restart my server every time I add a TW class that isn’t already in app.css.
Downgrading to 3.1.8 didn’t work for me.
If I’m not mistaken then when TW detects changes I should see something like this in my server output:
But I only ever see this when the server starts up. It never rebuilds again.
arrowsmith 2 minutes ago
I’m using Phoenix 1.7.9, Elixir 1.15.5, tailwind 0.2.2 (Hex package) and 3.3.5 (actual Tailwind lib). My
tailwind.config.jsis unchanged from the one generated bymix phx.new.Anyone have any ideas?
sodapopcan
How about your
config/config.exsTailwind config? Did you happen change anything there? Have you runmix tailwind defaultafter making changes? Just throwing out ideas here, I’m really not sure what could be wrong.arrowsmith
Turns out that I can reproduce this in a minimal Phoenix app:
That generates an app with Phoenix
1.7.10, tailwind hex package0.2.2, and tailwind version3.3.2as specified inconfig/config.exs.Now if I run
mix tailwind default --watchand openpriv/static/assets/app.css, I can see the generated tailwind utility classes. But if I change an.exor.heexfile inlib/tailwind_test_web, tailwind doesn’t rebuild. The only way I can force it to rebuild is to ctrl+C themix tailwind defaultprocess and start it again.