-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
The @tailwindcss/vite plugin (v4.1.18 or v4.2.1) reads the repo-level .gitignore when deciding which files to skip during source detection. There have been edge cases of which all of them are relevant today. It does not respect:
- Global gitignore (
core.excludesFile / ~/.gitignore_global) .git/info/exclude- Per-directory
.gitignorefiles in parent directories - Repository root
.gitignorefor monorepos if the app is in a workspace.
And has caused the following issues/discussions:
- Tailwind v4 @source directive ignores subdirectories with .gitignore #15452
- [v4]Can't resolve 'tailwindcss' in... #16661
- `[plugin:@tailwindcss/vite:generate:serve] Invalid code point 15530851` error after tailwind v3 -> v4 upgrade #18311
This causes Invalid code point crashes when ignored files (e.g. auto-generated
markdown with hex strings) are scanned and contain sequences that look like CSS hex
escapes.
Reproduce like this
- Add a file to your global gitignore (e.g. ALL_PROMPTS.md in ~/.gitignore_global)
- Place that file in the project with content containing a \ followed by 6+ hex
characters (e.g. \aaec5c) - Run vite dev — crashes with Invalid code point 11201628
Expected behaviour
File is ignored (git considers it ignored via git check-ignore -v)
Actual
File is scanned.
Tailwind scans the file, interprets \aaec5c as a CSS hex escape, calls String.fromCodePoint(0xaaec5c) which is 11201628 — beyond Unicode max (0x10FFFF), crashing with:
[plugin:@tailwindcss/vite:generate:serve] Invalid code point 11201628, hex sequence overflows `String.fromCodePoint()`Suggestion
Use git ls-files --others --ignored --exclude-standard or the ignore npm package with all standard gitignore sources, rather than only reading the repo .gitignore.
Workaround available
Option 1
Add @source not "../../SPECIFIC_FILE.md" in globals.css
Option 2
Add the file to the repo-level .gitignore. (does not work for monorepos, then add it to the workspace .gitignore instead.)
Option 3
Or you could just delete the file if you don't need it.