From 8ef28ee826128db6dc056c54632681c2649290b8 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Sat, 30 Jul 2022 22:38:35 +0800 Subject: [PATCH] fix: check undefined MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 翠 / green --- packages/vite/src/node/plugins/html.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/plugins/html.ts b/packages/vite/src/node/plugins/html.ts index 72e759210113dd..4ea9e9d9681b7d 100644 --- a/packages/vite/src/node/plugins/html.ts +++ b/packages/vite/src/node/plugins/html.ts @@ -789,10 +789,10 @@ export function preImportMapHook( ): IndexHtmlTransformHook { return (html, ctx) => { const importMapIndex = html.match(importMapRE)?.index - if (!importMapIndex) return + if (importMapIndex === undefined) return const moduleScriptIndex = html.match(moduleScriptRE)?.index - if (!moduleScriptIndex) return + if (moduleScriptIndex === undefined) return if (moduleScriptIndex < importMapIndex) { const relativeHtml = normalizePath(