Nextjs hot reloading taking 8-10 secs on every change of tailwind css

Pavan

I am learning Nextjs and trying to use tailwind css with it for the first time. I notice that every change I make to the index.css file on the class selector with @apply directive of tailwind is taking 8-10s to compile and show on the browser.

Steps to reproduce :

  1. Run the command

npx create-next-app --example with-tailwind-css test-app

  1. Create a button in pages/index.js and give it the classname btn-blue.

  2. Run the server using below command

npm run dev

  1. Change any property inside styles/index.css file for the btn-blue selector (Ex: change bg-blue-400 to bg-red-400 or so, anything to trigger a re-compile). And observe the time it takes to reflect the changes on the localhost at browser.

Some of my observation after experimenting :

  1. This slowness is only when making changes into the @apply style. If I comment all the tailwind code in the index.css and write my own pure css style and change it, the hot reload is instantaneous

  2. The hot reload is instant even when changing/adding any tailwind class to the classname of the element in index.js file (Inline styling).

So the issue seems to be only when using tailwind css from an external css file.

I hope you can check and help me on this. Thanks !

Pavan

I found out that this is an open issue (#13488) in the NextJs Github repo. Got the following workaround in the issue discussion thread and it is working like a charm (changes reflecting in less than a second).

Create two css files:

  1. With the tailwind imports (@tailwind base,utilities and components) (E.x tailwind.css)
  2. Your custom css file with the @apply rules and everything else. (E.x index.css)

Import both tailwind.css and index.css into your pages/_app.js file to apply the style globally.

Now any change you make to @apply in the index.css will reflect immediately in the localhost live server.

I have come to know that the same issue of using tailwind with Gatsby also exist so it may help in that case as well.

Hope you find this useful. Thanks

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Write to a specific file every 10 secs

Video thumbnail taking 10-15 secs to display

Nextjs with tailwind takes 8 - 16 seconds to complie

Tailwind CSS partially working in NextJS app

Tailwind CSS responsive behavior on nextjs app

Title not updating in nextjs, tailwind css app

Tailwind CSS html section not taking padding bottom

How to make jquery table which is refreshing itself in every 10 secs?

NextJs not found page keeps reloading every ~ 3 seconds

Taking a picture with 2 secs of delay

Docker hot reloading node app with nodemon using Windows 10

Android Studio Flutter Hot Reload For Every Change

Icons for Nextjs and tailwind layout

Problems with styling Nextjs & tailwind

Change color of button using css or tailwind

How to Read last lines from a big file with Go every 10 secs

tkinter GUI does not update Label every 10 secs and won't close

Spring properties hot reloading

Svelte Hot Reloading Issue

ServiceStack Hot Reloading Typescript

Reactjs hot reloading with electron

Use Tailwind Css to maintain a perfect Circle a cross every screen size

Why is Vuetify reloading the image every time other card properties change?

Ember-cli 0.2.5 livereload keeps reloading in every change

Nextjs Tailwind Marquee Component is overflowing

NextJs Tailwind header styling issue

Is there any function to remove all of the tailwind css classes remove from NextJs app?

Why my program with semaphore prints 20 secs instead of 10 secs?

Tailwind css: flex is not taking the full height of the parent div which is also flex