Rails 7 + Tailwind not refreshing css

I wanted to test the new integration of Tailwind CSS with Rails 7, just wrote a bit of code to see how this works… Normally, whenever the views are modified, the bundler should regenerate the CSS… but it does not. I need to stop the server (./bin/dev) and restart the server to see my changes. Any idea why?

To reproduce it

rails new tailwind --force --javascript=esbuild --css=tailwind
cd tailwind/
rails db:create
rails db:migrate
rails g controller demo show
./bin/dev
  1. Access localhost:3000/demo/show
  2. Then just modify the view demo/show.html.erb to use Tailwind css e.g.
<button class="bg-sky-500 hover:bg-sky-700 px-5 py-2 text-sm leading-5 rounded-full font-semibold text-white">
  Save changes
</button>
  1. Reload localhost:3000/demo/show

And you won’t see any tailwind style applied to the button without stoping/restarting the server.

1 Like

Me too,
Rails 7.0.2.3, ruby 3.1.0p0 [x86_64-linux] and executing

rails tailwindcss:build 

Later changes not refreshing after restarting apache webserver in any browser also gem “hotwire-livereload” isn’t working for his.

I’m in the same boat. Any updates on how you resolved this @coopeu , @Cedric_Lefebvre ?

So I figured it out. I ran the command rake assets:precomile locally for some reason. Likely was just following some guide to setup things. This created a bunch of files in my “/public/assets” folder. After I deleted all the files in that folder things went back to normal. Hope this saves someone else!

2 Likes

@daveomcd Saved my life, thanks a lot!