Skip to content

Conversation

@thecrypticace
Copy link
Contributor

@thecrypticace thecrypticace commented Aug 20, 2025

Breaking Change

We now fall back to v4 by default

Earlier versions of this plugin loaded a bundled version Tailwind CSS v3.x if no local install was found. This behavior remained even when you had configured the tailwindStylesheet option.

We'll now intelligently load either v4 or v3 based on some rules which are outlined (approximately) below:

Local Version Prettier Config Loaded version
none has tailwindStylesheet v4, bundled
none has tailwindConfig v3, bundled
none found v3 config file v3, bundled
none none v4, bundled
v3 has tailwindStylesheet v4, bundled
v3 has tailwindConfig v3, local
v3 found v3 config file v3, local
v3 none v3, local
v4 has tailwindStylesheet v4, local
v4 has tailwindConfig v3, bundled
v4 none v4, local

Notably, you can always force v4 by providing a tailwindStylesheet option — regardless of your local Tailwind CSS version. The same goes for v3.x and an explicit tailwindConfig option. If both are provided a warning is printed and the stylesheet takes precedence (and thus v4 is loaded).

If you do not provide a tailwindStylesheet when running v4 this plugin will use the default theme. You must provide this option if you customize your theme, variants, utilities, plugins, etc… otherwise some classes may sort incorrectly.


This bundles Tailwind CSS v4, it's relevant stylesheets, and intercepts their loading so users of the CDN or Standalone CLI can properly sort these without needing a local install through NPM.

This is a breaking change. We will still, however, search for a tailwind.config.js (or similar) in this scenario and load a bundled version of v3 if we find one. Specifying a stylesheet will force the plugin to load a bundled version of v4 if no local install exists.

Fixes #364

@thecrypticace thecrypticace added this to the 0.7.0 milestone Aug 20, 2025
@thecrypticace thecrypticace force-pushed the feat/better-monorepo-support branch from f7fc236 to 827e5f2 Compare August 29, 2025 16:03
Base automatically changed from feat/better-monorepo-support to main August 29, 2025 18:19
@thecrypticace thecrypticace marked this pull request as ready for review September 1, 2025 18:27
tailwindPackageName: 'tailwindcss-v4',
})

expect(result).toEqual('<div class="group peer unknown-class container p-0"></div>')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't unknown-class exist before group and peer? 🤔

Because while group and peer don't exist, they are still more known than unknown classes.

I don't know if we test this already, but named group and peers should be in a similar position.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In v4 we don't sort group and peer though

Copy link
Member

@RobinMalfait RobinMalfait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good (after you resolve the changelog conflict)

@thecrypticace thecrypticace merged commit 919349c into main Sep 2, 2025
1 check passed
@thecrypticace thecrypticace deleted the feat/add-v4-fallback branch September 2, 2025 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin sorts utilities with modifiers incorrectly if Tailwind is not installed

3 participants