Fix Next.js endless loop when setting a custom distDir
#15053
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #15050
In Tailwind CSS v4 Alpha 31 we changed how we scan template files. This changes included a new folder-dependency that is emitted for the
base
directory, so we can listen for new files being added as part of the postcss dependency.In our testing, this worked fine with the Next.js integration meaning a new file in the project root would be picked up by Oxide and we could update the CSS files accordingly.
This change is now, however, causing an issue. With Next.js 15 and with a custom
distDir
configured, the postcss build, that will write into thedistDir
, will cause another postcss run to be triggered, starting an endless loop (regardless of wether or not thedistDir
was also part of your gitignore list).This PR now changes the postcss client to not emit the base directory as a dependency to revert this changes. This does mean that new files and folders created directly in the project root will require a restart of the Next.js server again (just like it did in Alpha 31 and before) for now.
Test Plan
Next 15 does not seem to run in our current integration test setup (for some reason the server does not close correctly and it will fail on the cleanup step), so this change was tested manually:
tailwindcss
viapnpm build
tailwindcss-playgrounds
repo viapnpm install
With this setup I have tested changes to a template file (that causes new utilities to be added) and the CSS file (that will rebuild properly) across both
pnpm dev
andpnpm dev --turbo
. Furthermore integration tests assert it still works in Next 14 like it did before:Screen.Recording.2024-11-20.at.18.41.17.mov
One thing to make sure of is to include the new
distDir
into the.gitignore
file as well, otherwise we will scrape it for changes which inherently causes an endless loop issue again.