Skip to content

Update README.md#182

Merged
adamwathan merged 2 commits intotailwindlabs:mainfrom
lirobinxc:patch-1
Jul 17, 2023
Merged

Update README.md#182
adamwathan merged 2 commits intotailwindlabs:mainfrom
lirobinxc:patch-1

Conversation

@lirobinxc
Copy link
Copy Markdown
Contributor

@lirobinxc lirobinxc commented Jul 12, 2023

Using Prettier v3.x, this doesn't work.

// prettier.config.js
module.exports = {
  plugins: [require('prettier-plugin-tailwindcss')],
}

This does work:

// prettier.config.js (Prettier v3.x)
module.exports = {
  plugins: ['prettier-plugin-tailwindcss'],
}

See docs: https://prettier.io/docs/en/plugins.html

@adamwathan
Copy link
Copy Markdown
Member

Does the string approach work in both versions? If so let's just document that one 👍

@thecrypticace
Copy link
Copy Markdown
Contributor

thecrypticace commented Jul 12, 2023

Both options definitely work in both versions of Prettier (I tested this myself before release and again just now): https://github.com/prettier/prettier/blob/79d8a3983842d1d8a077f177ed8b983c1c596088/src/main/plugins/load-plugin.js#L28-L34

The require version is needed when using Prettier v2 + pnpm or Yarn PnP otherwise a string suffices.

@lirobinxc
Copy link
Copy Markdown
Contributor Author

lirobinxc commented Jul 13, 2023

Both options definitely work in both versions of Prettier (I tested this myself before release and again just now): https://github.com/prettier/prettier/blob/79d8a3983842d1d8a077f177ed8b983c1c596088/src/main/plugins/load-plugin.js#L28-L34

The require version is needed when using Prettier v2 + pnpm or Yarn PnP otherwise a string suffices.

I'm using Nuxt, where using 'require' gives me a Prettier config error. Could be my setup thou but after trying to debug, changing it to a string import is the only thing that solved it.

@thecrypticace
Copy link
Copy Markdown
Contributor

@lirobinxc what kind of setup are you using with Nuxt and Prettier? (Do you have a repro? I'd love to take a look). I just did a barebones install with a prettier config file and it works. But in this case Nuxt wouldn't really be involved anywhere. They just happen to be installed in the same project.

@eranhirsch
Copy link
Copy Markdown

I got an error from the prettier vscode plugin when using the require version, but everything worked when I ran it using npx prettier in the CLI. Removing the require and using the string instead seems to work for both now...

@adamwathan
Copy link
Copy Markdown
Member

Going to document just the string approach for now and wait for someone to find a situation where that breaks 🙃 Thanks!

@adamwathan adamwathan merged commit 1bc4f3e into tailwindlabs:main Jul 17, 2023
bronisMateusz pushed a commit to bronisMateusz/prettier-plugin-tailwindcss-drupal that referenced this pull request Apr 16, 2025
* Update README.md

* Update README.md

---------

Co-authored-by: Adam Wathan <[email protected]>
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.

4 participants