Replies: 10 comments 17 replies
-
Hey! v3 is JIT-only, so no way to generate the whole stylesheet I'm afraid. It would be several hundreds of megabytes with everything that is enabled/configured in v3 out of the box 😵💫 The only way to really pre-generate a more complete CSS file is by feeding Tailwind a complete list of class names you want included I'm afraid. Maybe a bit easier with pattern-based safelisting at least: |
Beta Was this translation helpful? Give feedback.
-
You could use the tailwind CDN for this! |
Beta Was this translation helpful? Give feedback.
-
This is also a big issue for us. We have our utilities living in a separate repo and package that is being used by multiple of our other repos. We have no context of which templates to use there. That means we can never update without doing huge changes in our codebase. Am I missing something? I think it's a weird decision to go full-jit mode and assume how people would or should work, not really a 'minor' breaking change like they claim.. Wouldn't hurt to have a non-jit mode, I mean we tinkered our configuration a lot over time for this. |
Beta Was this translation helpful? Give feedback.
-
If anyone is looking for an alternative to the tailwind config solution during development, BeyondCode just released their new tool for browser testing which inserts ALL tailwind classes for development. Please note that this is a paid solution ! Check it out here : https://devtoolsfortailwind.com |
Beta Was this translation helpful? Give feedback.
-
I can understand the reasoning behind not wanting to maintain multiple modes, but it also hurts discoverability (IDEs can't add completions for classes that don't exist.) Unless there's a workaround that I'm not aware of. FWIW I am a paying TailwindUI customer. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately you kind of killed in-browser template editing with that - especially for eG PHP projects. I was using custom purging and class generation from a JSON file to insert only the classes needed but without the JIT. Unfortunately the JIT is JS and not a custom declaration language - even though 95% of plugins are super simple, which makes it hard to run in eg PHP or Python backends. (That would be ideal) Fortunately there is a way to still get all classes via the new generation mechanism for those looking here: via the patterns. So I can continue to use that for the final production dynamic build at least. Identifying TW-classes in final HTML output is super simple using a tree structure btw. I can see it’s bad for the in-browser class adding feature though to load MBs of HTML. Probably the best would be to run the JIT inside of the browser in that case via a DOM mutation observer. I’ll explore more 👍. edit: Did not see your threaded response - fully understood. Would you be open to do JIT in a different way - where JIT-Engine can be implemented in PHP, Ruby, Python, …? |
Beta Was this translation helpful? Give feedback.
-
Yeah - this is a huge pain in the bum if we're building screens dynamically - now i'm just safelisting every class that I could ever use... Does anyone have a tailwind config that safelists everything with patterns? I need dark mode and opacity too - Here's my start:
What I really want is some utility function that I can feed in a list of classNames and it pulls in the classes on-demand instead of this ugly bloated approach... |
Beta Was this translation helpful? Give feedback.
-
@GiorgioG there is always Tailwind v2 and it works perfectly for now. That said we switched to a hybrid solution of hosted CDN and whitelisting classes. EG any class entered is retrieved from the browser and stored in the DB, a middleware is dynamically injecting the utilities styles. To do that I generated a heuristic to detect Tailwind classes on the rendered page and then checking if they are in a utilities.json (CSS to JSON structure) and only show those that are needed. The CDN is used for any fallback, but we are working to self-host a version and just have the middleware tell the JS code to create the missing classes. Seems to work so far. As long as we refresh the list of supported classes and have the CDN just as a fallback the build step is no longer such a big deal. |
Beta Was this translation helpful? Give feedback.
-
Using a custom pattern might help
See Playground |
Beta Was this translation helpful? Give feedback.
-
This change is really a no-sense. Makes custom tailwind builds unable to update to version 3. Not everyone needs JIT. |
Beta Was this translation helpful? Give feedback.
-
I know for Tailwind 3, JIT is the default mode, but is it the only mode?
Is there a way to change this to the old method of having what I realize will be an absolutely massive file for Tailwind 3? Perhaps in the config file with mode: "something" as there was mode: "jit" in Tailwind 2? Or is the mode option completely removed with no alternative.
It appears if you don't set the watch option, it requires that there be a content path specified and automatically autopurges, and if you don't specify content, it results in what appears to be basically just the normalize/reset stylesheet.
The reason I ask is I teach web development courses (HTML, CSS, and JS) at a community college. I use Tailwind not only to teach the students how to build websites using the framework, but I also use it as an opportunity to dig through Tailwind's CSS file to show teach them some of the more advanced CSS utilities that most frameworks don't implement, as well as all of the variants. (I'm not a fan of just saying "use this" without the how/why it works.)
If not, no worries -- I suppose from my understanding of how Tailwind does the purging (unless that has also changed) is it just keeps any class that is found as a string of text anywhere in the text file, and not just a class name on an HTML tag, and I can build a text file that lists all of the classes I want to go through and generate a CSS file from that, but particularly with the new variants being added, that may be a bit challenging to hit on everything.
Beta Was this translation helpful? Give feedback.
All reactions