Description
The @source
directive does not work when it contains a glob matching a symlink. It is a problem when we need to source a symlink directory that is versioned.
What version of Tailwind CSS are you using?
4.0.7
What build tool (or framework if it abstracts the build tool) are you using?
none
What version of Node.js are you using?
23.8
What browser are you using?
n/a
What operating system are you using?
Linux
Reproduction URL
https://github.com/borama/tw4-symlink-glob
Reproduction steps:
- benchmark test - globbing a real directory name (works OK)
$ cat input.css
@import "tailwindcss" source(none);
@source "ab*/*.html";
$ tree
.
├── abcd
│ └── xyz.html
└── input.css
$ cat abcd/xyz.html
<div class="bg-red-100">Hi</div>
$ tailwindcss -i input.css | grep bg-red-100
≈ tailwindcss v4.0.7
Done in 19ms
.bg-red-100 {
# the class has been added
- trying to glob a symlink name (does NOT work)
$ ln -s abcd efgh
$ tree
.
├── abcd
│ └── xyz.html
├── efgh -> abcd
└── input.css
# amend input.css to glob the symlink instead
$ cat input.css
@import "tailwindcss" source(none);
@source "ef*/*.html";
$ tailwindcss -i input.css | grep bg-red-100
≈ tailwindcss v4.0.7
Done in 19ms
# the class has not been added
Describe your issue
When the glob pattern in the @source
directive matches a directory name that is a symlink, Tailwind does not recognize it as a match and does not source the files inside it. This is a problem when a dependency that we want to source is versioned and symlinked (think efgh-3.4.123
in the test above) and we don't want to update the source whenever we upgrade the dependency.
Might be related to #16038 but I came across it in the context of ruby gems and this might be rather about the suffix *
matching than symlinked directory traversal.