-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
missing css in client manifest legacy chunks #10782
Comments
My naive hotfix for the time being is using the following pnpm patch: diff --git a/dist/node/chunks/dep-4da11a5e.js b/dist/node/chunks/dep-4da11a5e.js
index ef2d5d810506e20169239232d9972f1adf9bcdd8..114693e1473f068b95f016efa096ddf992521413 100644
--- a/dist/node/chunks/dep-4da11a5e.js
+++ b/dist/node/chunks/dep-4da11a5e.js
@@ -44284,7 +44284,7 @@ function cssPostPlugin(config) {
// this is a shared CSS-only chunk that is empty.
pureCssChunks.add(chunk.fileName);
}
- if (opts.format === 'es' || opts.format === 'cjs') {
+ if (opts.format === 'es' || opts.format === 'cjs' || opts.format === 'system') {
const cssAssetName = chunk.facadeModuleId
? normalizePath$3(path$n.relative(config.root, chunk.facadeModuleId))
: chunk.name; This is simply based on the fact that plugin-legacy sets vite/packages/plugin-legacy/src/index.ts Lines 323 to 328 in 1f57f84
I am not competent enough to tell if this is a valid approach or if it will break things under different circumstances. |
This is expected because legacy chunks uses the inlined CSS (#2062). |
I see. So I suppose that's a downstream problem in the sense that any downstream app should not rely on legacy chunks only? |
I guess using only legacy chunks will work because all the CSS used are inlined. Maybe you faced a bug caused by #9761 that affected Vite 3.1.x? |
Right, pinning vite to 3.2.3 makes nuxt-bridge work, however the result is unsatisfactory. Inlining CSS in a SSR build leads to the flash of unstyled content (FOUC). The server delivers pre-rendered HTML but the styles only appear after the entire set of scripts loads and starts. Legacy clients with no javascript (e.g. web crawlers) don't get any styles at all. I am not sure how to proceed here from the triage point of view. On the one hand, vite 3.2 works "as expected". On the other hand, the current "expected" behaviour is not friendly to the downstream SSR tooling that operates with legacy chunks. |
I think we can close this issue because avoiding inlining CSS in legacy is tracked in #2062. |
Describe the bug
When I generate a client manifest with
@vitejs/plugin-legacy
plugin enabled, legacy chunks are missingcss
entries.Example:
In the example above,
index.html
includes a css dependency, but the respectiveindex-legacy.html
does not.This is affecting third party libraries which rely on the manifest to inject the respective
<link rel="stylesheet">
into HTML head. For example: nuxt/bridge#561.Reproduction
https://stackblitz.com/edit/vitejs-vite-mjitx2?file=dist/manifest.json
Steps to reproduce
Run
npm install
followed bynpm run build
. Examinedist/manifest.json
.System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: