tailwindcss icon indicating copy to clipboard operation
tailwindcss copied to clipboard

[JIT]: JIT not working properly. like flex classes (next js)

Open MuttakinHasib opened this issue 5 years ago • 26 comments

What version of Tailwind CSS are you using?

v2.1.1

What build tool (or framework if it abstracts the build tool) are you using?

next.js 10.1.3

What version of Node.js are you using?

v14.15.1

What browser are you using?

Firefox, Chrome

What operating system are you using?

macOS

Reproduction repository

https://github.com/MuttakinHasib/tealeaf

Describe your issue

JIT not working properly... when i use classs like w-20 or flex classes its not working properly @adamwathan can you check my repo ? is it bug or i missed something ?

MuttakinHasib avatar Apr 23 '21 17:04 MuttakinHasib

Hi, could this possibly be addressed in release v2.1.2?

https://github.com/tailwindlabs/tailwindcss/releases/tag/v2.1.2

joshxyzhimself avatar Apr 23 '21 19:04 joshxyzhimself

Hey! Cloned and I can't reproduce any issues here, flex classes work as does w-20:

image image

Going to close but if this is still an issue please create a new issue with very specific steps to follow to see the issues you are seeing.

adamwathan avatar Apr 25 '21 11:04 adamwathan

With "tailwindcss": "^2.1.2" and the tailwind.config.js that looks like this:

module.exports = {
  mode: 'jit',
  future: {
    removeDeprecatedGapUtilities: true,
    purgeLayersByDefault: true,
  },
  purge: [
    './public/**/*.html',
    './components/**/*.{js,ts,jsx,tsx}',
    './pages/**/*.{js,ts,jsx,tsx}',
  ],
  variants: {},
}

...and running "dev": "next dev -p 8081"...

I experience the exact same issue as @MuttakinHasib.

<section className="px-12 mt-10 flex flex-col" style={{ minHeight: 410 }}>
  <ul className="mt-5 flex flex-1">
    <li className="w-24">
    </li>
  </ul>
</section>
  • [x] px-12 works
  • [x] mt-10 works
  • [ ] px-10 doesn't work (not shown here, but observed when changing classname)
  • [ ] my-10 doesn't either (not shown here, but observed when changing classname)
  • [x] flex works
  • [ ] flex-col doesn't work
  • [x] mt-5 works
  • [x] flex-1 works
  • [ ] w-24 doesn't work

It seems sorta consistent. Restarting the server doesn't resolve the issues.

Workaround is to run rm .next/cache -rf, and then restart the server. Then it works. This makes me assume that the cause isn't necessarily in JIT, but in how JIT output is picked up by next.js (or not picked up) or how the cache is breaking it.

SleeplessByte avatar Apr 29 '21 02:04 SleeplessByte

I'm also facing the exact same issue

lednhatkhanh avatar May 09 '21 16:05 lednhatkhanh

With "tailwindcss": "^2.1.2" and the tailwind.config.js that looks like this:

module.exports = {
  mode: 'jit',
  future: {
    removeDeprecatedGapUtilities: true,
    purgeLayersByDefault: true,
  },
  purge: [
    './public/**/*.html',
    './components/**/*.{js,ts,jsx,tsx}',
    './pages/**/*.{js,ts,jsx,tsx}',
  ],
  variants: {},
}

...and running "dev": "next dev -p 8081"...

I experience the exact same issue as @MuttakinHasib.

<section className="px-12 mt-10 flex flex-col" style={{ minHeight: 410 }}>
  <ul className="mt-5 flex flex-1">
    <li className="w-24">
    </li>
  </ul>
</section>
  • [x] px-12 works
  • [x] mt-10 works
  • [ ] px-10 doesn't work (not shown here, but observed when changing classname)
  • [ ] my-10 doesn't either (not shown here, but observed when changing classname)
  • [x] flex works
  • [ ] flex-col doesn't work
  • [x] mt-5 works
  • [x] flex-1 works
  • [ ] w-24 doesn't work

It seems sorta consistent. Restarting the server doesn't resolve the issues.

Workaround is to run rm .next/cache -rf, and then restart the server. Then it works. This makes me assume that the cause isn't necessarily in JIT, but in how JIT output is picked up by next (or not picked up) or how the cache is breaking it.

Hey, your workaround did the fix

thanhlmm avatar May 10 '21 15:05 thanhlmm

Im consistently experiencing the same issue, unconsistently. A restart after clearing the /.next cache always resolves it. I dont know why, maybe it is an Nextjs issue,

aludvigsen avatar Jun 01 '21 12:06 aludvigsen

@aludvigsen yeah... same here @adamwathan

MuttakinHasib avatar Jun 01 '21 13:06 MuttakinHasib

Please open a new issue with a reproduction ❤️

adamwathan avatar Jun 01 '21 14:06 adamwathan

I can't give you a consistent reproduction, so I won't open a new issue for the same problem that @MuttakinHasib reported and was closed because 'it couldn't be reproduced'. You'll just close that issue again with a "can't reproduce", and that would make sense :).

My mentioned workaround works consistently, but that should further indicate that this is a valid issue.

If someone does find a way to consistently reproduce this, that would be very helpful for everyone.

SleeplessByte avatar Jun 01 '21 23:06 SleeplessByte

Same issue here! I also notice it sometimes at my production builds when styles changes won't apply.

Hope it gets fixed soon.

kkallasm avatar Jun 02 '21 08:06 kkallasm

Can you folks try setting TAILWIND_DISABLE_TOUCH=true on the command line before starting your dev server? It'll use a different dependency tracking system that should be more resilient to how the persistent file cache in Webpack 5 works.

It would still be better if someone could create a minimal reproduction just so I know how it's all set up and can think through the possible reasons this problem could occur. It doesn't need to demonstrate the issue immediately, it's fine if the reproduction steps are "edit templates in the project for an hour and notice that eventually certain changes stop being picked up but it's different every time". It would just be helpful to see what version of webpack, what version of Next, how the purge paths are configured, what flags are being passed to Tailwind through environment variables, etc.

adamwathan avatar Jun 02 '21 10:06 adamwathan

I also noticed the same issue when working with Next.js -e with-tailwindcss which set tailwind's mode as "jit". After deleting the next cache, it works.

sandipndev avatar Jun 06 '21 14:06 sandipndev

I'm running into this issue in a yarn workspace with Next.js in a subdirectory. I'm not sure you'll be able to reproduce it right after a clone but it's happening for me locally. I noticed when it wouldn't generate text-3xl and -mb-4 but it looks like a caching thing so I don't think the missing classes actually matter. Once I deleted the .next directory and restarted, jit started working again.

I know this is hardly minimal but here goes.

https://github.com/Zertz/react-headless-tabs

  1. Run yarn in the root
  2. cd docs
  3. yarn dev
  4. 🤞

Zertz avatar Jun 13 '21 02:06 Zertz

I’m also experiencing the same regularly on both dev and production environments. I actually am always removing the .next directory before rebuilding the project to ensure the style changes are picked up.

What I wanted to add up is that I noticed this happening mostly when changing the value of the same utility repeatedly and sometimes when using arbitrary values as well.

This is of course all theoretical, but hopefully will help a little bit 😅

cheers

Elia-Darwish avatar Jun 17 '21 17:06 Elia-Darwish

Same thing happens, sadly am facing it that I have to clear the cache everytime i update a value, never happened before

with tailwind 2.1.2

mohux avatar Jun 27 '21 08:06 mohux

I am running into the same issue, but even clearing the cache isn't fixing it

octokatherine avatar Jul 11 '21 05:07 octokatherine

Hey @octokatherine, can you open a new issue and provide a reproduction? If we can see it not working on our own machines we can figure it out way, way faster.

Guesses:

  • Make sure on absolute latest version of everything (Next 11+, Tailwind 2.2+)
  • Make sure no mistakes in your purge config
  • Make sure not using string interpolation in your class names

adamwathan avatar Jul 11 '21 11:07 adamwathan

If your jit mode isn't working at all, try to structure your project like the one from this article. My issue was that jit wasn't working at all, but after reorganizing the project structure by following the linked article, now it works all the time.

starman-vlad avatar Jul 12 '21 09:07 starman-vlad

Im consistently experiencing the same issue, unconsistently. A restart after clearing the /.next cache always resolves it. I dont know why, maybe it is an Nextjs issue,

Do you know how we can clear cache in windows

hussamkhatib avatar Jul 13 '21 07:07 hussamkhatib

Stop the server. Yes, delete .next/cache in your project folder.

SleeplessByte avatar Jul 13 '21 16:07 SleeplessByte