Skip to content

Commit

Permalink
fix: dedupe assets
Browse files Browse the repository at this point in the history
  • Loading branch information
sun0day committed Sep 5, 2023
1 parent 787353c commit 66a3929
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/vite/src/node/plugins/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,26 @@ export function manifestPlugin(config: ResolvedConfig): Plugin {
}
}

let assetSet: Set<string> | null = null

if (chunk.viteMetadata?.importedAssets.size) {
manifestChunk.assets = [...chunk.viteMetadata.importedAssets]
assetSet = chunk.viteMetadata.importedAssets
}

if (chunk.viteMetadata?.importedCss.size) {
manifestChunk.css = [...chunk.viteMetadata.importedCss]
manifestChunk.css.forEach((cssFile) => {
const asset = fileNameToAssetMeta.get(cssFile)
if (asset?.importedAssets) {
manifestChunk.assets ||= []
manifestChunk.assets.push(...asset.importedAssets)
assetSet = new Set([...(assetSet || []), ...asset.importedAssets])
}
})
}

if (assetSet?.size) {
manifestChunk.assets = [...assetSet]
}

return manifestChunk
}

Expand Down

0 comments on commit 66a3929

Please sign in to comment.