-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Improve multi-root @config linking
#15001
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
295d2fc to
c005e24
Compare
Member
Author
|
This involves printing relative paths, so to make sure they work as expected I temporarily enabled the Windows tests to ensure everything works. You can see it passing here: https://github.com/tailwindlabs/tailwindcss/actions/runs/11854912553 |
RobinMalfait
commented
Nov 15, 2024
ef7e066 to
9547c9f
Compare
RobinMalfait
commented
Nov 17, 2024
f1a2a52 to
3324c9e
Compare
5d5112f to
9690804
Compare
RobinMalfait
commented
Nov 18, 2024
1. Sort by depth first 2. Sort by alphabetical folders 3. Prefer files starting with `index` 4. Sort alphabetically Before this change, when comparing two files, if they both started with `index`, then the sort was non-deterministic.
This ensures that the closest config file for a stylesheet is linked. We also write some information to the user so they can verify that the paths are correct (and adjust if necessary).
This ensures that once we figure out the absolute path, that we don't accidentally resolve it against the wrong `base`.
Other logs print files with backticks relative to the process. This makes it consistent.
Otherwise all file paths are white just like all the other text.
Because it needs to be Tailwind CSS v3
We are dealing with some paths...
This reverts commit 8fb759c.
Co-authored-by: Jordan Pittman <[email protected]>
20aa290 to
a00e9b4
Compare
adamwathan
approved these changes
Nov 18, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR improves the discoverability of Tailwind config files when we are trying to link them to your CSS files.
When you have multiple "root" CSS files in your project, and if they don't include an
@configdirective, then we tried to find the Tailwind config file in your current working directory.This means that if you run the upgrade command from the root of your project, and you have a nested folder with a separate Tailwind setup, then the nested CSS file would link to the root Tailwind config file.
Visually, you can think of it like this:
If you run the upgrade command from the root of your project, then the
/src/styles/index.csswill be linked to/tailwind.config.jswhich is what we expect.But
/admin/src/styles/index.csswill also be linked to/tailwind.config.jsWith this PR we improve this behavior by looking at the CSS file, and crawling up the parent tree. This mens that the new behavior looks like this:
Now
/src/styles/index.csswill be linked to/tailwind.config.js, and/admin/src/styles/index.csswill be linked to/admin/tailwind.config.js.When we discover the Tailwind config file, we will also print a message to the user to let them know which CSS file is linked to which Tailwind config file.
This should be a safe improvement because if your Tailwind config file had a different name, or if it lived in a sibling folder then Tailwind wouldn't find it either and you already required a
@config "…";directive in your CSS file to point to the correct file.In the unlikely event that it turns out that 2 (or more) CSS files resolve to the same to the same Tailwind config file, then an upgrade might not be safe and some manual intervention might be needed. In this case, we will show a warning about this.
Test plan:
Running this on Tailwind UI's codebase it looks like this: