File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -269,11 +269,15 @@ function VitePluginInspector(options: VitePluginInspectorOptions = DEFAULT_INSPE
269269 const scriptModuleInlineRE = / < s c r i p t \b (? = [ ^ > ] * \b t y p e \s * = \s * [ " ' ] m o d u l e [ " ' ] ) (? ! (?: [ ^ > ] * \b s r c \s * = ) ) ( [ ^ > ] * ) > ( [ \s \S ] * ?) < \/ s c r i p t > / gi
270270 const importRE = / \b i m p o r t \s + (?: [ \s \S ] * ?\s + f r o m \s + ) ? [ ' " ] ( [ ^ ' " ] + ) [ ' " ] / g
271271 const externalRE = / ^ (?: h t t p s ? : ) ? \/ \/ | ^ d a t a : / 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 }
You can’t perform that action at this time.
0 commit comments