diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index f1ae186932d4ee..933cb507a3150c 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -769,11 +769,15 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { // chunks instead. chunk.imports = chunk.imports.filter((file) => { if (pureCssChunkNames.includes(file)) { - const { importedCss } = (bundle[file] as OutputChunk) - .viteMetadata! + const { importedCss, importedAssets } = ( + bundle[file] as OutputChunk + ).viteMetadata! importedCss.forEach((file) => chunk.viteMetadata!.importedCss.add(file), ) + importedAssets.forEach((file) => + chunk.viteMetadata!.importedAssets.add(file), + ) return false } return true