Skip to content

[Bug]: assets from virtual CSS module break ssr-manifest.json by leaking into all chunks #94

Description

@ChumiChaCha

Demo URL

https://stackblitz.com/edit/vitejs-vite-dkfcgxck

What happened?

When build.ssrManifest: true is enabled in Vite, unplugin-fonts pollutes the entire ssr-manifest.json graph. The assets generated by the plugin (such as .woff2 font files, global SVGs, and images) leak into every single chunk in the manifest, including core runtime helpers (modulepreload-polyfill.js, @vue/reactivity, etc.).

This completely breaks the purpose of SSR chunk optimization, as the SSR server reads this manifest and forces the browser to preload every single font and image asset globally on every page request.

Reproduction steps

1. Open the provided reproduction link.
2. Run `npm run build` in the terminal.
3. Inspect the generated `ssr-manifest.json` file.

*Note for StackBlitz:* The `.vite` folder is hidden by default in the sidebar. To inspect the generated manifest after building, run this command in the terminal:
`cat dist/.vite/ssr-manifest.json`

Relevant log output

{
  "\u0000unfonts.css": [
    "/assets/vite-BF8QNONU.svg",
    "/assets/hero-CLDdwZDr.png",
    "/assets/Roboto-Bold-CjXAX5wa.woff2",
    "/assets/Roboto-Medium-B3yustc1.woff2",
    "/assets/Roboto-Regular-BQDBHXny.woff2"
  ],
  "\u0000vite/modulepreload-polyfill.js": [
    "/assets/vite-BF8QNONU.svg",
    "/assets/hero-CLDdwZDr.png",
    "/assets/Roboto-Bold-CjXAX5wa.woff2",
    "/assets/Roboto-Medium-B3yustc1.woff2",
    "/assets/Roboto-Regular-BQDBHXny.woff2"
  ],
  "node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js": [
    "/assets/vite-BF8QNONU.svg",
    "/assets/hero-CLDdwZDr.png",
    "/assets/Roboto-Bold-CjXAX5wa.woff2",
    "/assets/Roboto-Medium-B3yustc1.woff2",
    "/assets/Roboto-Regular-BQDBHXny.woff2"
  ]
}

What browsers are you seeing the problem on?

No response

What is your operating system?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions