Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
psaren committed Apr 13, 2021
1 parent c9e0bcf commit 8cb1c0d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/vite/src/node/plugins/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
},

async generateBundle(_, bundle) {
const analyzedChunk: Map<OutputChunk, number> = new Map()
const getPreloadLinksForChunk = (
chunk: OutputChunk,
seen: Set<string> = new Set()
Expand Down Expand Up @@ -294,12 +295,16 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
seen: Set<string> = new Set()
): HtmlTagDescriptor[] => {
const tags: HtmlTagDescriptor[] = []
chunk.imports.forEach((file) => {
const importee = bundle[file]
if (importee && importee.type === 'chunk') {
tags.push(...getCssTagsForChunk(importee, seen))
}
})
if (!analyzedChunk.has(chunk)) {
analyzedChunk.set(chunk, 1)
chunk.imports.forEach((file) => {
const importee = bundle[file]
if (importee && importee.type === 'chunk') {
tags.push(...getCssTagsForChunk(importee, seen))
}
})
}

const cssFiles = chunkToEmittedCssFileMap.get(chunk)
if (cssFiles) {
cssFiles.forEach((file) => {
Expand Down

0 comments on commit 8cb1c0d

Please sign in to comment.