Skip to content

[Suggestion] Vite plugin could use git's ignore rules instead of parsing .gitignore directly #19801

@webbertakken

Description

@webbertakken

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 .gitignore files in parent directories
  • Repository root .gitignore for monorepos if the app is in a workspace.

And has caused the following issues/discussions:

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

  1. Add a file to your global gitignore (e.g. ALL_PROMPTS.md in ~/.gitignore_global)
  2. Place that file in the project with content containing a \ followed by 6+ hex
    characters (e.g. \aaec5c)
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions