Prettier configuration for Tailwind CSS and Kirby CMS

I want to use Tailwind’s class sorting plugin for Prettier but I need to set up a .prettierignore file and I’m not really familiar with the gitignore syntax or what files I should ignore? I’m guessing I should ignore all of the files except for Kirby’s template, snippet related files?

Could anyone share their Kirby CMS .prettierignore file? Thank you

Prettier does not support PHP templates, so it won’t even try to format those. But you can totally use Prettier to format blueprints or JS files.

For class sorting, I’ve came accross two solutions in the past:

  • rustywind is a CLI tool for class-sorting using a regex-based approach which works fine with PHP files. You can configure your IDE to run the CLI on save. It’s my recommended approach.
  • Headwind for VS Code or Tailwind Formatter for JetBrains IDEs should work too, but might not support all utilities because of being unmaintained for a while.

Thanks for the reply. I’m using Sublime Text. Just to clarify, are you saying the Tailwind Prettier plugin won’t sort classes inside a PHP template or Prettier won’t “pretty” PHP code?

If the Tailwind Prettier plugin doesn’t work with PHP templates, I wonder how Laravel devs are sorting Tailwind classes?

Prettier doesn’t support mixed PHP code, and as the Prettier plugin relies on Prettier working with PHP files, formatting as well as class sorting in PHP files doesn’t work.

Laravel has its own template language (Blade) - which in comparison - has Prettier support via some plugins. But there is no PHP plugin that supports mixed PHP code (which is what Kirby uses by default)