DEV Community

Discussion on: Getting started with Rails 6.1, TailwindCSS JIT, Webpacker & PostCSS 8

Collapse
 
curting profile image
Oliver Curting

Hi David! Thanks a bunch for your walkthrough. Very helpful!
That being said, when running bin/webpack-dev-server it keeps re-compiling every second. As a result the page keeps refreshing. Any thoughts on how to fix that?

All the best,
Oliver

Collapse
 
davidteren profile image
David Teren

Hey Oliver, thanks so much for the feedback.
What version of Ruby are you running?

Collapse
 
alistairtweed profile image
Alistair Tweed

I'm experiencing the same issue on Ruby 2.7.3.

Thread Thread
 
scotti_jack profile image
Jack Scotti

same issue on Ruby 3.0.1

Thread Thread
 
xertrov profile image
Max Kaye • Edited

Edit: I think I was wrong below. Here's what worked: try setting compile: false in webpacker.yml and commenting mode: 'jit', in tailwind.config.js. I can run bin/webpack-dev-server, rails s, and guard at the same time now without issue or compile-refresh loops.


This started happening to me after I got tailwind working. Are you running some live-reloading tool? (e.g., I was running bundle exec guard.) If so, try not running that. bin/webpack-dev-server handles livereloading when running, it seems.

NB: webpack-dev-server would almost always compile things twice for me (now) but stops after that (until I make another change).

I also noticed that commenting mode: 'jit', in tailwind.config.js seemed to fix it too, before I stopped running guard.

You can also just not run bin/webpack-dev-server -- rails s will still compile stuff for you and then you can have bundle exec guard in the bg if you prefer that.

Collapse
 
keijsvog profile image
Koen Eijsvogels

Hi Oliver,

I followed above instructions and got the same issue as you did.
I changed the tailwind.config.js a little bit: I did not use ./**/*.html.erb in the purge section but ./app/**/*.html.erb. This solved for me the issue of the recompiling.

Collapse
 
davidteren profile image
David Teren

Thanks for that. It was pointed out to me by someone else as well and came here to change it and saw your comment now only. 🤦‍♂️