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-tailwindcss are limited to:
- JavaScript
- Supports babel parser by default, and supports oxc parser from
v0.9.0.
- TypeScript
- Supports typescript parser by default, and supports babel-ts parser and oxc-ts parser from
v0.9.0.
- Vue (
v0.3.0 or higher)
- Astro (
v0.6.0 or higher)
- Angular, HTML, Svelte (
v0.7.0 or higher)
Support for other languages requires further development.
-
You need to add prettier-plugin-merge to 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-tailwindcss will be used.
By reordering the two plugins, now only prettier-plugin-classnames is used.
I created prettier-plugin-merge to overcome this limitation of Prettier.
prettier-plugin-merge uses 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:
Now Prettier will only use prettier-plugin-merge among the three plugins, but prettier-plugin-merge will use prettier-plugin-tailwindcss and prettier-plugin-classnames sequentially.
So the class names will be sorted first and then wrapped.
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:v0.9.0.v0.9.0.v0.3.0or higher)v0.6.0or higher)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.{ "plugins": [ "prettier-plugin-classnames", // ignored "prettier-plugin-tailwindcss" ] }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.