Skip to content

Commit e2658ad

Browse files
authored
perf(css): only replace empty chunk if imported (#16349)
1 parent c0ec6be commit e2658ad

File tree

1 file changed

+5
-1
lines changed
  • packages/vite/src/node/plugins

1 file changed

+5
-1
lines changed

packages/vite/src/node/plugins/css.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
860860
for (const file in bundle) {
861861
const chunk = bundle[file]
862862
if (chunk.type === 'chunk') {
863+
let chunkImportsPureCssChunk = false
863864
// remove pure css chunk from other chunk's imports,
864865
// and also register the emitted CSS files under the importer
865866
// chunks instead.
@@ -874,11 +875,14 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
874875
importedAssets.forEach((file) =>
875876
chunk.viteMetadata!.importedAssets.add(file),
876877
)
878+
chunkImportsPureCssChunk = true
877879
return false
878880
}
879881
return true
880882
})
881-
chunk.code = replaceEmptyChunk(chunk.code)
883+
if (chunkImportsPureCssChunk) {
884+
chunk.code = replaceEmptyChunk(chunk.code)
885+
}
882886
}
883887
}
884888

0 commit comments

Comments
 (0)