You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have created a tailwindcss plugin, it need to configure with process.cwd(), Tailwind CSS intelliSenece works well, but prettier-plugin-tailwindcss encounter error like:
The text was updated successfully, but these errors were encountered:
yunsii
changed the title
load tailwind config with process.cwd() encounter error in WSL
Load tailwind config with process.cwd() encounter error in WSL
Aug 26, 2023
Hey! So the Prettier plugin loads files relative to the Prettier config. It doesn't consult or change the current working directory because doing so can cause other problems.
For example, we'd have to change the CWD just before loading the config and then change it back at the end of parse() because doing so has the potential to invalidate assumptions in Prettier itself. Additionally, in environments like VSCode, Prettier extension loads Prettier into the VSCode extension itself in a worker thread. Worker threads do not support process.chdir() and even some operating systems don't support the idea of per-thread working directories. Additionally, in VSCode the CWD in an extension is an ill-defined concept because the working directory of the extension host is often unrelated to the actively-edited workspace.
In your situation it'd be better to use something like __dirname in your Tailwind config file to make the path relative to the file itself rather than the directory in which you happened to run the prettier command.
What version of
prettier-plugin-tailwindcss
are you using?v0.5.3
What version of Tailwind CSS are you using?
v3.3.3
What version of Node.js are you using?
v16.14.0
What package manager are you using?
pnpm
What operating system are you using?
WSL
Reproduction URL
https://github.com/yunsii/prettier-plugin-tailwindcss-reproduction-20230826
Describe your issue
I have created a tailwindcss plugin, it need to configure with
process.cwd()
, Tailwind CSS intelliSenece works well, but prettier-plugin-tailwindcss encounter error like:It looks like prettier-plugin-tailwindcss not change dir to correct workspace dir? my tailwindcss plugin config: https://github.com/yunsii/prettier-plugin-tailwindcss-reproduction-20230826/blob/master/tailwind.config.ts#L13
The text was updated successfully, but these errors were encountered: