Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The content config is relative to the cwd, not the config location #10497

Closed
arcanis opened this issue Feb 5, 2023 · 2 comments
Closed

The content config is relative to the cwd, not the config location #10497

arcanis opened this issue Feb 5, 2023 · 2 comments

Comments

@arcanis
Copy link

arcanis commented Feb 5, 2023

What version of Tailwind CSS are you using?

3.2.4

What build tool (or framework if it abstracts the build tool) are you using?

postcss (as a JS API; I don't use the CLI)

What version of Node.js are you using?

n/a

What browser are you using?

n/a

What operating system are you using?

n/a

Describe your issue

Take the following code; as you can see, Tailwind fails to see that the files referenced in tailwind.config.js exist:
https://runkit.com/arcanis/63e022537347590008b0d296

It works if I use process.chdir to move inside the website folder, or if I use __dirname instead of ./:
https://runkit.com/arcanis/63e023088424060008aa8a47

While those are reasonable options, resolving paths relative to the configuration file that declares them (rather than unstable process cwd) is a fairly common pattern, so the current behaviour is a little unexpected, at least when the Tailwind function is provided an explicit configuration path (of course, when passing an object, using the cwd is acceptable).

@arcanis
Copy link
Author

arcanis commented Feb 5, 2023

Seems to be duplicate with #6516, addressed in part by #6516 (comment). However the default behaviour is still surprising to me - I understand it may be difficult / impossible to change it outside of a major, but perhaps the error message should be updated to clearly point out the problem? For example:

The 'content' configuration matched 17 files but none of them contained any CSS classes. Adding
'relative: true' to your configuration would have matched 132 classes. Did you forget to define it?

See this link for more details: https://tailwindcss.com/docs/content-configuration#using-relative-paths

@thecrypticace
Copy link
Contributor

thecrypticace commented Feb 6, 2023

Hey! So the default behavior is something we want to (and are likely to) change for v4 later this year. I definitely can see how it's surprising which is why we want to make it the default. Lots of ideas and stuff are up in the air for v4 but I'm pretty sure that change is settled.

Alongside that we've had a plan for a while on a command that does these kinds of additional checks for you but "out-of-band" because of the potential performance impact.

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

No branches or pull requests

2 participants