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

[Bug?]: cssChunking / CSS Optimisations - Module CSS getting reset by tailwind's global styles #69311

Closed
rohitpotato opened this issue Aug 26, 2024 · 7 comments
Labels
bug Issue was opened via the bug report template. create-next-app Related to our CLI tool for quickly starting a new Next.js application. locked Navigation Related to Next.js linking (e.g., <Link>) and navigation. please simplify reproduction Please simplify the reproduction. stale

Comments

@rohitpotato
Copy link

Link to the code that reproduces this issue

https://github.com/GabenGar/repros/blob/main/nextjs/css-out-of-order/README.md

To Reproduce

  1. Upgrade to NextJs version 14.2.5
  2. Build prod
  3. Write some CSS inside a .module.css file.
  4. See the changes

Current vs. Expected behavior

Tailwind CSS's preflight styles overwrite Tailwind CSS written inside module CSS.

Example:

button.module.css

.button {
 @apply bg-red-500;
}

Expected Behaviour: Button color is red.

Current Behaviour: Button color is transparent since module CSS is overwritten by tailwind's preflight styles.

Provide environment information

Relevant packages:

Next - 14.2.5

Which area(s) are affected? (Select all that apply)

Not sure, create-next-app, Navigation

Which stage(s) are affected? (Select all that apply)

next build (local), Other (Deployed)

Additional context

We have a big legacy project where we have written tailwind classes inside module CSS by using the apply directive. At some places, these styles are being reset by Tailwind's preflight styles. This started happening after the next JS upgrade to version 14.2.5 and we are unable to move further.

I have tried the cssChunking as per the documentation but that is having no effect.

Is there any workaround? Rewriting everything back to tailwind classes is a very bandwidth heavy task for our team.

@rohitpotato rohitpotato added the bug Issue was opened via the bug report template. label Aug 26, 2024
@github-actions github-actions bot added create-next-app Related to our CLI tool for quickly starting a new Next.js application. Navigation Related to Next.js linking (e.g., <Link>) and navigation. labels Aug 26, 2024
@vercel vercel deleted a comment Aug 26, 2024
@alexanderbira
Copy link

This is related to #64921

@samcx samcx added the please simplify reproduction Please simplify the reproduction. label Sep 4, 2024
Copy link
Contributor

github-actions bot commented Sep 4, 2024

We cannot easily recreate the issue with the provided information. Please add a minimal reproduction in order for us to be able to help more efficiently.

Why was this issue marked with the please simplify reproduction label?

There was a reproduction provided, but due to its complexity, we cannot easily reproduce the issue.

An ideal minimal reproduction (unless relevant):

  • is not part of a monorepo
  • does not require secrets to run
  • does not reference private registry dependencies
  • has as few dependencies as possible
  • excludes unrelated pages/routes
  • does not require a database/third-party service to run
  • only includes the code necessary to reproduce the issue
  • is tested against next@canary to make sure your issue has not already been fixed

In general, assume that we should not go through a lengthy onboarding process at your company code only to be able to verify an issue.

If you cannot create a clean reproduction, another way you can help the maintainers' job is to pinpoint the canary version of next that introduced the issue. Check out our releases, and try to find the first canary release that introduced the issue. This will help us narrow down the scope of the issue, and possibly point to the PR/code change that introduced it. You can install a specific version of next by running npm install next@<version>.

What happens if I don't provide a sufficient minimal reproduction?

Issues with the please simplify reproduction label that receive no meaningful activity (e.g. new comments with a simplified reproduction link) are automatically closed and locked after 30 days.

If your issue has not been resolved in that time and it has been closed/locked, please open a new issue with the required reproduction.

I did not open this issue, but it is relevant to me, what can I do to help?

Anyone experiencing the same issue is welcome to provide a minimal reproduction following the above steps.

I think my reproduction is good enough, why aren't you looking into it quicker?

We look into every Next.js issue and constantly monitor open issues for new comments.

However, sometimes we might miss one or two due to the popularity/high traffic of the repository. We apologize, and kindly ask you to refrain from tagging core maintainers, as that will usually not result in increased priority.

Providing a minimal reproduction from the start without asking helps us look into issues much more quickly, as we can easily verify if the reported bug is related to Next.js. That said, every issue is important to us, and if an issue gets closed by accident, we encourage you to open a new one linking to the old issue and we will look into it.

Useful Resources

@samcx
Copy link
Member

samcx commented Sep 4, 2024

@rohitpotato If we can get a simpler :repro: outside of your :monorepo:, that will be great!

@rohitpotato
Copy link
Author

@samcx its a private repo, i cant really share the code. But the above sandbox is as simple as it gets. Please check with this if possible.

@samcx
Copy link
Member

samcx commented Sep 5, 2024

@rohitpotato I'm afraid there is way too much going on in that repository for us to dig into.

Ideally, a :repro: would only contain your Layout + Page, your tailwind global styles, and the module.css for the Page.

Are you intermixing Client and Server components? That might be part of the issue.

@balazsorban44
Copy link
Member

This issue has been automatically closed because it received no activity for a month and had no reproduction to investigate. If you think it was closed by accident, please leave a comment. If you are running into a similar issue, please open a new issue with a reproduction. Thank you.

@balazsorban44 balazsorban44 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 6, 2024
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. create-next-app Related to our CLI tool for quickly starting a new Next.js application. locked Navigation Related to Next.js linking (e.g., <Link>) and navigation. please simplify reproduction Please simplify the reproduction. stale
Projects
None yet
Development

No branches or pull requests

5 participants
@balazsorban44 @samcx @rohitpotato @alexanderbira and others