missing css in client manifest legacy chunks
See original GitHub issueDescribe the bug
When I generate a client manifest with @vitejs/plugin-legacy
plugin enabled, legacy chunks are missing css
entries.
Example:
{
"index-legacy.html": {
"file": "assets/index-legacy.1b2bcd2a.js",
"src": "index-legacy.html",
"isEntry": true
},
"vite/legacy-polyfills-legacy": {
"file": "assets/polyfills-legacy.907dbd91.js",
"src": "vite/legacy-polyfills-legacy",
"isEntry": true
},
"index.html": {
"file": "assets/index.9f336c05.js",
"src": "index.html",
"isEntry": true,
"css": [
"assets/index.824f0ed3.css"
]
},
"index.css": {
"file": "assets/index.824f0ed3.css",
"src": "index.css"
}
}
In the example above, index.html
includes a css dependency, but the respective index-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: https://github.com/nuxt/bridge/issues/561.
Reproduction
https://stackblitz.com/edit/vitejs-vite-mjitx2?file=dist/manifest.json
Steps to reproduce
Run npm install
followed by npm run build
. Examine dist/manifest.json
.
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 16.14.2 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 7.17.0 - /usr/local/bin/npm
npmPackages:
@vitejs/plugin-legacy: ~2.3.0 => 2.3.0
vite: ~3.2.1 => 3.2.2
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
manifest.json does not include assets · Issue #2375 · vitejs/vite
Statically imported assets (SVG file in my case) will get bundled and created in the outDir , but are missing in the generated...
Read more >Micro Frontend Architecture: Import chunks from another ...
Challenge 4: Missing Dependency Resolution. What happens if a chunk is interleaved into an app which doesn't have one of the dependencies the...
Read more >Code Splitting - webpack
Prevent Duplication: Use Entry dependencies or SplitChunksPlugin to dedupe and split chunks. Dynamic Imports: Split code via inline function calls within ...
Read more >Server-Side Rendering - Vite
The manifest contains mappings of module IDs to their associated chunks and asset files. To leverage the manifest, frameworks need to provide a...
Read more >From O(4G) to (Offline) - Lessons learned from performance
The tool is useful for optimizing code and abstracting source code into smaller pieces of code (chunks). To build global stylesheets, webpack wasn't...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.