From 7a1af060f96e88df4c859c2ccb21d68c570541b9 Mon Sep 17 00:00:00 2001
From: Gnohz Gniy <0x00eeee@gmail.com>
Date: Fri, 14 Jun 2024 15:31:41 +0800
Subject: [PATCH] Fix __VITE_PRELOAD__ regression in vite 5.3
---
src/index.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/index.ts b/src/index.ts
index b36657d..f5c5fd5 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -27,7 +27,7 @@ const defaultConfig = { useRecommendedBuildConfig: true, removeViteModuleLoader:
export function replaceScript(html: string, scriptFilename: string, scriptCode: string, removeViteModuleLoader = false): string {
const reScript = new RegExp(``)
// we can't use String.prototype.replaceAll since it isn't supported in Node.JS 14
- const preloadMarker = /"__VITE_PRELOAD__"/g
+ const preloadMarker = /"?__VITE_PRELOAD__"?/g
const newCode = scriptCode.replace(preloadMarker, "void 0")
const inlined = html.replace(reScript, (_, beforeSrc, afterSrc) => ``)
return removeViteModuleLoader ? _removeViteModuleLoader(inlined) : inlined