@@ -8,7 +8,7 @@ import { SYNC_QRL } from '../../../core/qrl/qrl-class';
8
8
import type { OptimizerSystem , Path , QwikManifest , SymbolMapper , SymbolMapperFn } from '../types' ;
9
9
import clickToComponentSrc from './click-to-component.html?raw' ;
10
10
import errorHost from './error-host.html?raw' ;
11
- import imageDevTools from './image-size-runtime.html?raw' ;
11
+ import imageDevToolsSrc from './image-size-runtime.html?raw' ;
12
12
import perfWarning from './perf-warning.html?raw' ;
13
13
import { parseId , type NormalizedQwikPluginOptions } from './plugin' ;
14
14
import type { QwikViteDevResponse } from './vite' ;
@@ -27,7 +27,7 @@ function getOrigin(req: IncomingMessage) {
27
27
return `${ protocol } ://${ host } ` ;
28
28
}
29
29
30
- function createSymbolMapper ( base : string ) : SymbolMapperFn {
30
+ function createSymbolMapper ( base : string , srcRelative : string ) : SymbolMapperFn {
31
31
return (
32
32
symbolName : string ,
33
33
_mapper : SymbolMapper | undefined ,
@@ -45,7 +45,7 @@ function createSymbolMapper(base: string): SymbolMapperFn {
45
45
}
46
46
// In dev mode, the `parent` is the Vite URL for the parent, not the real absolute path.
47
47
// It is always absolute but when on Windows that's without a /
48
- const qrlFile = `${ base } ${ parent . startsWith ( '/' ) ? parent . slice ( 1 ) : parent } _${ symbolName } .js` ;
48
+ const qrlFile = `${ base } ${ srcRelative } ${ parent . startsWith ( '/' ) ? parent . slice ( 1 ) : parent } _${ symbolName } .js` ;
49
49
return [ symbolName , qrlFile ] ;
50
50
} ;
51
51
}
@@ -77,7 +77,10 @@ export async function configureDevServer(
77
77
clientDevInput : string | undefined ,
78
78
devSsrServer : boolean
79
79
) {
80
- symbolMapper = lazySymbolMapper = createSymbolMapper ( base ) ;
80
+ symbolMapper = lazySymbolMapper = createSymbolMapper (
81
+ base ,
82
+ opts . srcDir ? `${ path . relative ( opts . rootDir , opts . srcDir ) } /` : ''
83
+ ) ;
81
84
if ( ! devSsrServer ) {
82
85
// we just needed the symbolMapper
83
86
return ;
@@ -212,7 +215,7 @@ export async function configureDevServer(
212
215
if ( 'html' in result ) {
213
216
res . write ( ( result as any ) . html ) ;
214
217
}
215
- res . write ( END_SSR_SCRIPT ( opts , base ) ) ;
218
+ res . write ( END_SSR_SCRIPT ( path , opts , base ) ) ;
216
219
res . end ( ) ;
217
220
} else {
218
221
next ( ) ;
@@ -376,25 +379,30 @@ function relativeURL(url: string, base: string) {
376
379
return url ;
377
380
}
378
381
379
- const DEV_QWIK_INSPECTOR = ( opts : NormalizedQwikPluginOptions [ 'devTools' ] , base : string ) => {
382
+ const DEV_QWIK_INSPECTOR = ( path : Path , opts : NormalizedQwikPluginOptions , base : string ) => {
383
+ const { srcDir, rootDir } = opts ;
384
+ const srcRelative = srcDir ? `${ path . relative ( rootDir , srcDir ) } /` : '' ;
385
+ const { clickToSource, imageDevTools } = opts . devTools ;
380
386
const qwikdevtools = {
381
- hotKeys : opts . clickToSource ?? [ ] ,
387
+ hotKeys : clickToSource ?? [ ] ,
382
388
} ;
383
389
return (
384
390
`<script>
385
391
globalThis.qwikdevtools = ${ JSON . stringify ( qwikdevtools ) } ;
386
392
</script>` +
387
- ( opts . imageDevTools ? imageDevTools : '' ) +
388
- ( opts . clickToSource ? clickToComponentSrc . replaceAll ( '{{BASE}}' , base ) : '' )
393
+ ( imageDevTools ? imageDevToolsSrc : '' ) +
394
+ ( clickToSource
395
+ ? clickToComponentSrc . replaceAll ( '{{BASE}}' , base ) . replaceAll ( '{{SRC}}' , srcRelative )
396
+ : '' )
389
397
) ;
390
398
} ;
391
399
392
- const END_SSR_SCRIPT = ( opts : NormalizedQwikPluginOptions , base : string ) => `
400
+ const END_SSR_SCRIPT = ( path : Path , opts : NormalizedQwikPluginOptions , base : string ) => `
393
401
<style>${ VITE_ERROR_OVERLAY_STYLES } </style>
394
402
<script type="module" src="/@vite/client"></script>
395
403
${ errorHost }
396
404
${ perfWarning }
397
- ${ DEV_QWIK_INSPECTOR ( opts . devTools , base ) }
405
+ ${ DEV_QWIK_INSPECTOR ( path , opts , base ) }
398
406
` ;
399
407
400
408
function getViteDevIndexHtml ( entryUrl : string , serverData : Record < string , any > ) {
0 commit comments