@@ -24,8 +24,8 @@ import {
2424 type SharedConfig ,
2525 type UserPluginConfig ,
2626} from './types.js'
27-
2827import type { ConfigEnv , Plugin , Logger } from 'vite'
28+
2929const sharedConfigKeys : ( keyof SharedConfig ) [ ] = [ 'enableBuild' , 'overlay' ]
3030const buildInCheckerKeys : BuildInCheckerNames [ ] = [
3131 'typescript' ,
@@ -63,7 +63,7 @@ export function checker(userConfig: UserPluginConfig): Plugin {
6363 let initializeCounter = 0
6464 let checkers : ServeAndBuildChecker [ ] = [ ]
6565 let isProduction = false
66- let devBase = '/'
66+ let baseWithOrigin : string
6767 let viteMode : ConfigEnv [ 'command' ] | undefined
6868 let buildWatch = false
6969 let logger : Logger | null = null
@@ -99,7 +99,7 @@ export function checker(userConfig: UserPluginConfig): Plugin {
9999 } ,
100100 configResolved ( config ) {
101101 logger = config . logger
102- devBase = config . base
102+ baseWithOrigin = config . server . origin ? config . server . origin + config . base : config . base
103103 isProduction ||= config . isProduction || config . command === 'build'
104104 buildWatch = ! ! config . build . watch
105105 } ,
@@ -126,7 +126,7 @@ export function checker(userConfig: UserPluginConfig): Plugin {
126126 }
127127
128128 if ( id === wrapVirtualPrefix ( RUNTIME_CLIENT_ENTRY_PATH ) ) {
129- return composePreambleCode ( devBase , overlayConfig )
129+ return composePreambleCode ( { baseWithOrigin , overlayConfig } )
130130 }
131131
132132 return
@@ -139,7 +139,7 @@ export function checker(userConfig: UserPluginConfig): Plugin {
139139 {
140140 tag : 'script' ,
141141 attrs : { type : 'module' } ,
142- children : composePreambleCode ( devBase , overlayConfig ) ,
142+ children : composePreambleCode ( { baseWithOrigin , overlayConfig } ) ,
143143 } ,
144144 ]
145145 } ,
0 commit comments