Set up Tailwind CSS JIT in a Rails project to compile styles 20x faster

07-Apr-2021 1764
Tailwind CSS gained quite a lot of traction in the world of Ruby and Rails. We even have the official tailwindcss-rails gem blessed by DHH himself that you can use with good ol’ Asset Pipeline if, for some reason, you stay away from Webpacker, ES6 modules, and processing CSS with webpack.I joined the Tailwind army about a year ago when I started working on a new demo application for AnyCable. I was amazed by the powerful yet simple development flow: fast prototyping via Tailwind Play, componentization via @apply, and the built-in PurgeCSS integration for smaller compiled CSS files.Everything seemed perfect except for the one thing: a bit slower re-compilation in development (using webpack-dev-server) than I expected. The reason was that Webpack had to recompile all the Tailwind CSS styles whenever anything changed in the bundle. You can read more about the problem and the possible workaround in this article.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle