@@ -24,8 +24,8 @@ import {
24
24
type SharedConfig ,
25
25
type UserPluginConfig ,
26
26
} from './types.js'
27
-
28
27
import type { ConfigEnv , Plugin , Logger } from 'vite'
28
+
29
29
const sharedConfigKeys : ( keyof SharedConfig ) [ ] = [ 'enableBuild' , 'overlay' ]
30
30
const buildInCheckerKeys : BuildInCheckerNames [ ] = [
31
31
'typescript' ,
@@ -63,7 +63,7 @@ export function checker(userConfig: UserPluginConfig): Plugin {
63
63
let initializeCounter = 0
64
64
let checkers : ServeAndBuildChecker [ ] = [ ]
65
65
let isProduction = false
66
- let devBase = '/'
66
+ let baseWithOrigin : string
67
67
let viteMode : ConfigEnv [ 'command' ] | undefined
68
68
let buildWatch = false
69
69
let logger : Logger | null = null
@@ -99,7 +99,7 @@ export function checker(userConfig: UserPluginConfig): Plugin {
99
99
} ,
100
100
configResolved ( config ) {
101
101
logger = config . logger
102
- devBase = config . base
102
+ baseWithOrigin = config . server . origin ? config . server . origin + config . base : config . base
103
103
isProduction ||= config . isProduction || config . command === 'build'
104
104
buildWatch = ! ! config . build . watch
105
105
} ,
@@ -126,7 +126,7 @@ export function checker(userConfig: UserPluginConfig): Plugin {
126
126
}
127
127
128
128
if ( id === wrapVirtualPrefix ( RUNTIME_CLIENT_ENTRY_PATH ) ) {
129
- return composePreambleCode ( devBase , overlayConfig )
129
+ return composePreambleCode ( { baseWithOrigin , overlayConfig } )
130
130
}
131
131
132
132
return
@@ -139,7 +139,7 @@ export function checker(userConfig: UserPluginConfig): Plugin {
139
139
{
140
140
tag : 'script' ,
141
141
attrs : { type : 'module' } ,
142
- children : composePreambleCode ( devBase , overlayConfig ) ,
142
+ children : composePreambleCode ( { baseWithOrigin , overlayConfig } ) ,
143
143
} ,
144
144
]
145
145
} ,
0 commit comments