vite: { legacy: false }
: In SSR build, styles are not extracted correctly
#1334
Labels
vite: { legacy: false }
: In SSR build, styles are not extracted correctly
#1334
Environment
Reproduction
Nuxt Bridge:https://stackblitz.com/~/github.com/medz/github-avnkvf - ❌
Nuxt 3: https://stackblitz.com/~/github.com/medz/github-8bvs9l - ✅
Describe the bug
After running
nuxi build
, components or page styles are not extracted correctlyAdditional context
Nuxt Bridge:
Nuxt 3:
Desc
By comparing the output of Nuxt Bridge and Nuxt 3, it is found that Nuxt Bridge does not extract css correctly, which causes the page style to be applied later.
Through the browser execution order, it is found that in Nuxt Bridge, the browser needs to download the component or page JS before applying the style in JS.
Correct behavior
Entering the page, the page and component styles should be extracted to the head (external css should set the correct link) but Nuxt Bridge + vite does not
Tip
It is worth noting that this behavior is correct in
webpack
.The reason why I enabled vite is that Nuxt2 and Nuxt Bridge only use
webpack@v4
, which makes many tool chains unable to upgrade. (Most of them rely onwebpack@v5
)Logs
No response
The text was updated successfully, but these errors were encountered: