vanilla-extract icon indicating copy to clipboard operation
vanilla-extract copied to clipboard

Next.js: Styles not loading after navigation with mixed pages/app

Open edenstrom opened this issue 1 year ago • 4 comments

Describe the bug

This is a continuation of #1152 with a new reproduction.

Having a project half migrated to the app directory breaks the CSS in the pages in /pages.

The code that fixes the CSS loading in pages only checks that the app directory is created, not that it's in use for that specific page.

How to reproduce

  1. Open reproduction
  2. Navigate from pages: home to pages: other. CSS of pages: other is not loaded
  3. Refresh the page. CSS is now loaded
  4. Navigate to pages: home. CSS of pages: home is not loaded now
  5. Navigating from/to the app directory routes works.

Reproduction

https://stackblitz.com/edit/stackblitz-starters-xzcmes

System Info

System:
    OS: macOS 14.2.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 542.77 MB / 32.00 GB
    Shell: 3.7.0 - /opt/homebrew/bin/fish
  Binaries:
    Node: 18.19.1 - ~/Library/Caches/fnm_multishells/34040_1712568811215/bin/node
    npm: 10.2.4 - ~/Library/Caches/fnm_multishells/34040_1712568811215/bin/npm
    pnpm: 8.15.6 - ~/Library/Caches/fnm_multishells/34040_1712568811215/bin/pnpm
    bun: 1.0.33 - ~/.bun/bin/bun
  Browsers:
    Chrome: 123.0.6312.107
    Safari: 17.2.1
  npmPackages:
    @vanilla-extract/css: 1.14.2 => 1.14.2
    @vanilla-extract/dynamic: 2.1.0 => 2.1.0
    @vanilla-extract/next-plugin: 2.4.0 => 2.4.0
    @vanilla-extract/vite-plugin: ^3.9.2 => 3.9.5
    vite: ^5.1.3 => 5.1.4
    webpack: ^5.88.2 => 5.90.0

Used Package Manager

pnpm

Logs

No response

Validations

edenstrom avatar Apr 08 '24 09:04 edenstrom

Same issue, confirmed https://github.com/vanilla-extract-css/vanilla-extract/issues/1152 doesn't fix

"next": "^14.0.4"
"@vanilla-extract/css": "^1.15.1"
"@vanilla-extract/next-plugin": "^2.4.0"

huypham50 avatar Jun 11 '24 15:06 huypham50

Note that this issue doesn't appear with css module: https://stackblitz.com/edit/stackblitz-starters-2ebzry

So it's seems to be related to vanilla extract

zecka avatar Jul 11 '24 07:07 zecka

This issue seems related to this one https://github.com/vercel/next.js/issues/53858

zecka avatar Jul 11 '24 12:07 zecka