Skip to content

Extra empty CSS chunks when returning CSS in the load plugin hook #267

Closed
@eltigerchino

Description

@eltigerchino

Describe the bug

When returning a CSS module type in the load plugin hook, an empty CSS chunk is generated in addition to the returned CSS. This is an issue for SvelteKit because we traverse the CSS imports from the viteMetadata property to inline them but these empty chunks are included in the imports, but do not exist in the Vite manifest that's generated from the build.

Reproduction

https://stackblitz.com/edit/vitejs-vite-pddcqpsd?file=vite.config.ts,README.md

Steps to reproduce

  1. Install dependencies with pnpm i and run the build with pnpm build
  2. Notice there is an empty CSS chunk in dist/index.css
  3. Remove the custom plugin from vite.config.ts that returns a CSS module
  4. Re-run the build with pnpm build
  5. Observe that the empty CSS chunk is not produced.

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: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    rolldown-vite:  6.3.21

Used Package Manager

pnpm

Logs

No response

Validations

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions