From 55ad23ed44af35cb34c81881bdb12bff844c913e Mon Sep 17 00:00:00 2001 From: Touchumind Date: Sat, 27 Feb 2021 02:39:13 +0800 Subject: [PATCH] fix(build): css tags injection priority (#2272) --- packages/vite/src/node/plugins/html.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/vite/src/node/plugins/html.ts b/packages/vite/src/node/plugins/html.ts index e4c97a1c5c9c78..cd147519332bce 100644 --- a/packages/vite/src/node/plugins/html.ts +++ b/packages/vite/src/node/plugins/html.ts @@ -294,6 +294,12 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin { seen: Set = new Set() ): HtmlTagDescriptor[] => { const tags: HtmlTagDescriptor[] = [] + 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) => { @@ -309,12 +315,6 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin { } }) } - chunk.imports.forEach((file) => { - const importee = bundle[file] - if (importee && importee.type === 'chunk') { - tags.push(...getCssTagsForChunk(importee, seen)) - } - }) return tags }