Allow resolving content paths relative to the config file #9396
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Right now we resolve content paths relative the the current working directory ("CWD"). If you run the CLI from a different location than the current working directory you can get unexpected results.
As an example, let's say that your config says that your content files live under
./src/pages/**/*.js
and./src/components/**.js
. If you run Tailwind CSS usingnpx tailwindcss build …
from inside thesrc/
directory then Tailwind will complain about not being able to find any content paths. This doesn't make much sense because, to the user, the content is relative to the "project root" — which is almost always where their config file is.So, we've added an option
content.relative
that lets you specify this behavior explicitly:This will let you run Tailwind CSS from anywhere and it will resolve the file paths relative the location of the config file. If you do NOT use a config file (because you're passing an object, because you're using Nuxt with it's Tailwind CSS plugin, or some other third party solution) then the paths are resolved relative to the current working directory.
This is a change we intend to make the default behavior in the future for v4 — as such we've added a flag
future.relativeContentPathsByDefault
that enables this behavior by default. This allows you to keep using thearray
syntax for content paths instead of needing the object:Fixes #6516