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

[v4] Sources are not being taken into consideration with Next.js 15 #15876

Closed
AssisrMatheus opened this issue Jan 26, 2025 · 8 comments · Fixed by #15941
Closed

[v4] Sources are not being taken into consideration with Next.js 15 #15876

AssisrMatheus opened this issue Jan 26, 2025 · 8 comments · Fixed by #15941

Comments

@AssisrMatheus
Copy link

Tailwind: 4.0.0
Next.js: 15.1.6
MacOS: Sequoia 15.2
Node: v22.13.1
pnpm: 9.15.3
Arc Browser: 1.79.0

Reproduction URL

https://github.com/AssisrMatheus/tailwindv4-next15-no-output-repro

Setup process:

  1. pnpx create-next-app@latest
  2. pnpx @tailwindcss/upgrade@next
  3. pnpm run dev

Describe your issue

In a brand new next.js 15 project. Tailwind v4 is only building base css and theme variables, all classes used within source files are ignored.

I have tried to turn off turbopack with no success. Rolling back node to v20 also doesn't help. Tried using postcss.config.json file format instead of current one also with no success.

Current behaviour:
Image

Expected behaviour:
Image

@AssisrMatheus AssisrMatheus changed the title [v4] Sources are being taken into consideration with Next.js 15 [v4] Sources are not being taken into consideration with Next.js 15 Jan 26, 2025
@wongjn
Copy link
Contributor

wongjn commented Jan 26, 2025

Seems to be working fine for me:

Image

Perhaps try deleting the .next folder and restarting the dev server?

@AssisrMatheus
Copy link
Author

Enregistrement.d.ecran.le.2025-01-26.a.10.39.44.mov

Have also tried that before, unfortunately doesn't fix it

@MathieuUrstein
Copy link

Hello wongjn I'm in the exact same situation as AssisrMatheus. Tailwind is there in the css output but does not pick up any classes found in tsx files.

What do your environment look like?

Mine is the following:

@tailwindcss/postcss: 4.0.0
next: 15.1.6
postcss: 8.5.1
react: 19.0.0
tailwindcss: 4.0.0
typescript: 5.7.3
node: 22.13.0
npm: 10.9.2
macOS: 14.6.1

PS: tried removing .next folder. I even tried creating a completely new project by following the nextjs installation guide from scratch

@wongjn
Copy link
Contributor

wongjn commented Jan 26, 2025

Consider checking if you have any .gitignore files higher up the file tree.

@MathieuUrstein
Copy link

MathieuUrstein commented Jan 26, 2025

Indeed it was the issue for me.
I have a .gitignore in my home directory where I publish my zsh config and some other script which makes my home ignore file look like this:

*  <--- this is the issue
!.gitignore
!.zshrc
...

Then I have some projects inside my home directory. Is there a way to configure tailwind or postcss to limit the upper scope? I tried @import "tailwindcss" source("../"); or even

@import "tailwindcss" source(none);
@source "../";

with no success.

I could also move my projects outside my home directory, but I think this scenario might happen to other people

@wongjn
Copy link
Contributor

wongjn commented Jan 26, 2025

I haven't seen a way to configure tailwind or postcss to limit the upper scope unfortunately. The scanning is done in Rust, using WalkBuilder from the ignore crate:

pub fn resolve_paths(root: &Path) -> impl Iterator<Item = DirEntry> {
WalkBuilder::new(root)
.hidden(false)
.require_git(false)

pub fn read_dir(root: &Path, depth: Option<usize>) -> impl Iterator<Item = DirEntry> {
WalkBuilder::new(root)
.hidden(false)
.require_git(false)

RobinMalfait added a commit that referenced this issue Jan 28, 2025
Right now, when Oxide is scanning for files, it considers ignore files
in the "root" directory it is scanning as well as all parent
directories.

We honor .gitignore files even when not in a git repo as an optimization
in case a project has been created, contains a .gitignore, but no repo
has actually been initialized. However, this has an unintended side
effect of including ignore files _ouside of a repo_ when there is one.
This means that if you have a .gitignore file in your home folder it'll
get applied even when you're inside a git repo which is not what you'd
expect.

This PR addresses this by checking to see the folder being scanned is
inside a repo and turns on a flag that ensures .gitignore files from the
repo are the only ones used (global ignore files configured in git still
work tho).

This still needs lots of tests to make sure things work as expected.

Fixes #15876

---------

Co-authored-by: Robin Malfait <[email protected]>
@goodpixels
Copy link

I have the same issue as @MathieuUrstein . Unfortunately your answer @wongjn doesn't really help at all.

@wongjn
Copy link
Contributor

wongjn commented Feb 4, 2025

I'd hoped my response would at least give some context. I'm sorry it didn't live up to your expectations.

This issue should have been fixed by #15941. Are you still experiencing explicit problems with files not being read due to a .gitignore higher up the file tree?

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

Successfully merging a pull request may close this issue.

4 participants