@@ -315,8 +315,9 @@ function analyzeResultFiles(
315
315
// This mimics the Webpack dev-server behavior.
316
316
filePath = '/index.html' ;
317
317
} else {
318
- filePath = normalizePath ( file . path ) ;
318
+ filePath = '/' + normalizePath ( file . path ) ;
319
319
}
320
+
320
321
seen . add ( filePath ) ;
321
322
322
323
// Skip analysis of sourcemaps
@@ -458,21 +459,19 @@ export async function setupServer(
458
459
// Remove query if present
459
460
const [ importerFile ] = importer . split ( '?' , 1 ) ;
460
461
461
- source = normalizePath (
462
- join ( dirname ( relative ( virtualProjectRoot , importerFile ) ) , source ) ,
463
- ) ;
464
- }
465
- if ( source [ 0 ] === '/' ) {
466
- source = source . slice ( 1 ) ;
462
+ source =
463
+ '/' +
464
+ normalizePath ( join ( dirname ( relative ( virtualProjectRoot , importerFile ) ) , source ) ) ;
467
465
}
466
+
468
467
const [ file ] = source . split ( '?' , 1 ) ;
469
468
if ( outputFiles . has ( file ) ) {
470
469
return join ( virtualProjectRoot , source ) ;
471
470
}
472
471
} ,
473
472
load ( id ) {
474
473
const [ file ] = id . split ( '?' , 1 ) ;
475
- const relativeFile = normalizePath ( relative ( virtualProjectRoot , file ) ) ;
474
+ const relativeFile = '/' + normalizePath ( relative ( virtualProjectRoot , file ) ) ;
476
475
const codeContents = outputFiles . get ( relativeFile ) ?. contents ;
477
476
if ( codeContents === undefined ) {
478
477
if ( relativeFile . endsWith ( '/node_modules/vite/dist/client/client.mjs' ) ) {
@@ -590,7 +589,7 @@ export async function setupServer(
590
589
return ;
591
590
}
592
591
593
- const rawHtml = outputFiles . get ( 'index.server.html' ) ?. contents ;
592
+ const rawHtml = outputFiles . get ( '/ index.server.html' ) ?. contents ;
594
593
if ( ! rawHtml ) {
595
594
next ( ) ;
596
595
0 commit comments