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

css from dependencies get higher priority over local css #59374

Open
1 task done
poulet42 opened this issue Dec 7, 2023 · 2 comments
Open
1 task done

css from dependencies get higher priority over local css #59374

poulet42 opened this issue Dec 7, 2023 · 2 comments
Labels
bug Issue was opened via the bug report template.

Comments

@poulet42
Copy link

poulet42 commented Dec 7, 2023

Link to the code that reproduces this issue

https://github.com/poulet42/repro-vendor-css-next

To Reproduce

Context

The reproduction repository uses turborepo to highlight the issue with an external package.

in packages/ui/button.module.css, the background of the button is set to red.
in apps/web/app/page.module.css, the background of the button is set to blue. The class is passed to the button with a className prop.

Reproduction instructions

with app router

  1. start the "web" application (pnpm dev --filter=web)
  2. the button appears to be red, inspect the page.css file, the style from ui appears after the page style
    --

with pages router

  1. start the "docs" application (pnpm dev --filter=docs)
  2. the button appears to be blue, inspect the style, the style from ui appears before the page style

Current vs. Expected behavior

Style from "vendors" should not take precedence over local app style, or at least there should be a way to control the order.

So vendor styles should appear before the app styles.

Screenshot 2023-12-07 at 17 41 56

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.2.0: Thu Nov  9 06:29:23 PST 2023; root:xnu-10002.60.71.505.1~3/RELEASE_ARM64_T6000
Binaries:
  Node: 21.2.0
  npm: 10.2.3
  Yarn: N/A
  pnpm: 8.9.0
Relevant Packages:
  next: 14.0.4-canary.47
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A

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

App Router

Additional context

Can't say which canary introduced this, but it does work with the page router.

@poulet42 poulet42 added the bug Issue was opened via the bug report template. label Dec 7, 2023
@melodyarcjason
Copy link

I am encountering this issue myself. My reproduction steps:

  1. Load landing page - content appears as expected with proper styling applied.
  2. Navigate to another page in the application
  3. Return to home page via router.push('/')
  4. Observe the styles are being overwritten by dependency defaults

(My local style is prefixed with homePage_logoContainer)
Initial Load:
image

Load after navigating back:
image

@Netail
Copy link
Contributor

Netail commented Mar 5, 2024

Experiencing the same issue, but with the app router. Related; #64921

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

3 participants