Skip to content
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

Non-existence of .git directory breaks tailwind styles #17080

Open
danielsomerfield opened this issue Mar 9, 2025 · 8 comments
Open

Non-existence of .git directory breaks tailwind styles #17080

danielsomerfield opened this issue Mar 9, 2025 · 8 comments

Comments

@danielsomerfield
Copy link

What version of Tailwind CSS are you using?

v4.0.12

What build tool (or framework if it abstracts the build tool) are you using?

For example: postcss-cli 11.0.0, Next.js 15.1.7, Vite 6.1.0

Vite 6.2.1

What version of Node.js are you using?

v22.14.0

What browser are you using?

chrome

What operating system are you using?

macos

Reproduction URL

  • Following the instructions here
  • When prompted whether to init a git project, choose "No".
  • Run the project with npm dev
  • Navigate to the URL and notice that the text is not centered
  • Go to your project root and run mkdir .git
  • Kill the npm process and run npm dev again
  • Navigate to the URL and notice that the text now is centered

Describe your issue

It appears that the existence or non-existence of the .git directory effects the behaviour of the app. If you simply create an empty .git directory, all works. The existence or non existence of .gitignore appears to have no effect.

@philipp-spiess
Copy link
Member

Hey! One thing that I can think of if you do not have a .git folder, is that our .gitignore heuristics will walk up your file system and try to find any .gitignore file in parents. Can you take a look if your parent folders have any .gitignore that might interfere? You should be able to run a bash script like this:

current="$PWD"
while [ "$current" != "/" ]; do
  if [ -f "$current/.gitignore" ]; then
    echo "$current/.gitignore"
  fi
  current=$(dirname "$current")
done

@philipp-spiess
Copy link
Member

I've been trying out the reproduction and it works regardless of the .git folder being present on my machine.

@DrLightman
Copy link

DrLightman commented Mar 12, 2025

On the contrary my .gitignore seems to be ignored, and whenever I commit something Tailwindcss cli echoes ~10 lines of "Done in ms"

All I can think of that gets modified during a commit is something inside /.git, a directory that should be ignored I presume.

Also directories in .gitignore are still monitored by the tailwindcss cli and not ignored, if I delete a file from an ignored root dir, eg: /.work/ the tailwindcss cli still echoes ~10 lines of "Done in ms"

Not 100% related to the op but it's just to let you know maybe something needs to be looked into regarding .git and .gitignore.

@philipp-spiess
Copy link
Member

@DrLightman Hey! Mind create a new GitHub issue for this with a reproduction? We don't add any git hooks or interfere with the .git folder in any way (we just use the information of the .gitignore file to know which files we can avoid scanning (i.e your node_modules/ folder).

@philipp-spiess
Copy link
Member

@danielsomerfield Hey! Did you have the chance to look into weather a parent .gitignore interferes with the setup? :)

@danielsomerfield
Copy link
Author

danielsomerfield commented Mar 21, 2025

I think you're on to something. My project is a combined UI and backend project and so the directory structure is:

/
   .gitignore
   ui/
      package.json
      app/
   service/

I just tried it in a clean directory and all was fine. Then I tried it in a directory that had a .gitignore directory above it and it repro'ed. So, yes, it looks like it only occurs if there is a .gitignore in a parent directory.

@philipp-spiess
Copy link
Member

@danielsomerfield What's the content of the .gitignore file for when this issue occurs?

@danielsomerfield
Copy link
Author

It looks like virtualenv created a file at some point way upstream that had *. Delete that file and it seems ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants