-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Can I use this plugin with prettier-plugin-tailwindcss?
Of course! However, there are a few notes.
-
Languages that can be used with
prettier-plugin-tailwindcssare limited to:- JavaScript
- TypeScript
- Vue (
v0.3.0or higher) - Astro (
v0.6.0or higher) - Angular, HTML, Svelte (
v0.7.0or higher)
Support for other languages requires further development.
-
You need to add
prettier-plugin-mergeto your Prettier configuration.This is because if two or more plugins are configured to format a particular language, Prettier will only use the last of those plugins.
So, for example, if you configure it like this, only
prettier-plugin-tailwindcsswill be used.By reordering the two plugins, now only
prettier-plugin-classnamesis used.{ "plugins": [ "prettier-plugin-tailwindcss", // ignored "prettier-plugin-classnames" ] }I created
prettier-plugin-mergeto overcome this limitation of Prettier.prettier-plugin-mergeuses the plugins listed before it sequentially to format and merge them.So, to allow Prettier to use
prettier-plugin-merge, change the configuration as follows:{ "plugins": [ "prettier-plugin-tailwindcss", "prettier-plugin-classnames", "prettier-plugin-merge" ] }Now Prettier will only use
prettier-plugin-mergeamong the three plugins, butprettier-plugin-mergewill useprettier-plugin-tailwindcssandprettier-plugin-classnamessequentially.So the class names will be sorted first and then wrapped.
{ "plugins": [ "prettier-plugin-classnames", // ignored "prettier-plugin-tailwindcss" ] }