- [vitejs/vite#4198] CSS input missing from manifest.json
- [vitejs/vite#2375] manifest.json does not include assets
Turns out, Vite's built in manifest plugin IS able to generate CSS entrypoints in manifest.json. In fact, I accidentally discovered this when trying to adapt the internal plugin with minimal changes.
The reason why we don't see this behavior is because the manifest plugin runs at the very end of the plugin chain. Pure CSS entrypoints chunk is removed by another built-in plugin.
Therefore, to simply have CSS entrypoints to show up in manifest.json, just use the built-in manifest plugin as a user plugin since they run before any built-in plugins run.
The below shows example on how to workaround the current limitation of the built in plugin
I am not going to publish an npm package for this workaround, since it seems like this issue is soon to be fixed [vitejs/vite#6649]. Feel free to do so if you find it easier.
-
The css entrypoints generated in the manifest.json has a
file
field that points to a NON-EXISTING js file, not a problem since manifest.json is only used in backend integrations, just generate the<link/>
tags from thecss
array. -
It is OK to disable the built in manifest file, since the outputs of both manifest are IDENTICAL, except for the css entries (or maybe other assets entrypoints)
-
If you use
build.cssCodeSplit = false
, please note that this workaround WILL NOT work. The entrypoint still shows up, but withoutcss
field.