Skip to content

Commit b6a09e8

Browse files
committed
fix: strip config.base prefix when resolving bundledDev entry modules
1 parent 057fdcd commit b6a09e8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/core/src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,15 @@ function VitePluginInspector(options: VitePluginInspectorOptions = DEFAULT_INSPE
269269
const scriptModuleInlineRE = /<script\b(?=[^>]*\btype\s*=\s*["']module["'])(?!(?:[^>]*\bsrc\s*=))([^>]*)>([\s\S]*?)<\/script>/gi
270270
const importRE = /\bimport\s+(?:[\s\S]*?\s+from\s+)?['"]([^'"]+)['"]/g
271271
const externalRE = /^(?:https?:)?\/\/|^data:/i
272+
const configBase = config.base?.replace(/\/$/, '') || ''
272273
function resolveEntryModule(src: string, htmlDir: string) {
273274
// Strip query/hash suffixes and skip external URLs
274-
const cleaned = src.replace(/[?#].*$/, '')
275+
let cleaned = src.replace(/[?#].*$/, '')
275276
if (externalRE.test(cleaned) || !cleaned)
276277
return
278+
// Strip config.base prefix from absolute URLs
279+
if (cleaned.startsWith('/') && configBase && cleaned.startsWith(configBase))
280+
cleaned = cleaned.slice(configBase.length) || '/'
277281
const base = cleaned.startsWith('/') ? config.root : htmlDir
278282
htmlEntryModules.add(normalizePath(path.resolve(base, cleaned.replace(/^\//, ''))))
279283
}

0 commit comments

Comments
 (0)