Skip to content

Automatically sort classes based on recommended class order, like prettier-plugin-tailwindcss plugin #269

Answered by dcastil
pingustar asked this question in Ideas
Discussion options

You must be logged in to vote

Hey @pingustar! 👋

thanks, I'm happy to hear you like the library!

I think sorting the output of the twMerge function within tailwind-merge isn't a good idea. Here are a couple reasons:

  1. tailwind-merge only runs at runtime, so the sorting would only happen after the code was already sent to the browser. Therefore it wouldn't help with compression of the code sent over the wire to the browser. That's unless you're using SSR and running tailwind-merge on the server. But in that case the HTML is still a minority of the data sent and the classes are still unsorted in the sent JS code which hydrates the app.
  2. Sorting in the same way as prettier-plugin-tailwindcss would require me to add a lot of…

Replies: 3 comments 8 replies

Comment options

You must be logged in to vote
2 replies
@pingustar
Comment options

@steveoh
Comment options

Answer selected by pingustar
Comment options

You must be logged in to vote
2 replies
@dcastil
Comment options

@soutot
Comment options

Comment options

You must be logged in to vote
4 replies
@dcastil
Comment options

@spacecat
Comment options

@dcastil
Comment options

@spacecat
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
context-v1 Related to tailwind-merge v1
5 participants