Skip to content

[v4] Tailwind running with Next v15 on Docker takes ton of time and resources for first load #15882

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

Closed
lentscode opened this issue Jan 26, 2025 · 3 comments · Fixed by #17255
Closed

Comments

@lentscode
Copy link

What version of Tailwind CSS are you using?

v4.0.0

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

Next.js v15.1.4

What version of Node.js are you using?

v23.0.0

What browser are you using?

N/A

What operating system are you using?

MacOS

Reproduction URL

I have an issue running Next v15 + Tailwind v4 on a Docker container: the first compiling takes a huge amount of time compared to running yarn dev on local. Furthermore, it takes a ton of CPU and memory just for the first rendering.

Local yarn dev
Image

Docker container
Image

docker stats
Image

@philipp-spiess
Copy link
Member

Hey! My guess is that COPY . . within your Dockerfile ignores dotfiles somehow? Tailwind CSS v4 will look at your .gitignore file to figure out which files should not be scanned by the compiler for CSS classes so if this file is not present, it will also go into your node_modules which might contain a loooot of files to scan.

@lentscode
Copy link
Author

lentscode commented Jan 27, 2025

Hey! My guess is that COPY . . within your Dockerfile ignores dotfiles somehow? Tailwind CSS v4 will look at your .gitignore file to figure out which files should not be scanned by the compiler for CSS classes so if this file is not present, it will also go into your node_modules which might contain a loooot of files to scan.

I inspected the running container using docker exec -it CONTAINER ID sh and then ls -a and found the .gitignore file, so that should not be the problem.
Thanks for your call though. In my project I did not include the .gitignore file in the container and the time spent in the first compiling went from 30 seconds to 10 seconds 😅.

However, the problem persists, but it's not as bad as I thought.

@philipp-spiess
Copy link
Member

I've tried running your repro on my machine but somehow can't connect to the dev server started inside the container. Are you doing anything other than docker run <container-name>?

I'm curious if you have looked at full-build times too and if this issue only appears when you add the Tailwind CSS postcss plugin?

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.

2 participants