Skip to content

Commit

Permalink
fix(plugin-vite): only in vite development mode to set rendererUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcherGu committed Jul 6, 2024
1 parent 53ebe4d commit fa9a58f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/plugin-vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,14 @@ export function VitePluginDoubleshot(userConfig: Partial<VitePluginDoubleshotCon

let pack: (() => Promise<void>) | undefined

// to save vite mode
let viteMode = 'development'

const configureForMode = async (resolvedConfig: ResolvedConfig) => {
const { mode } = resolvedConfig
viteMode = mode

if (typeof userConfig.configureForMode === 'function') {
const { mode } = resolvedConfig
await userConfig.configureForMode(userConfig, mode)
}
}
Expand All @@ -71,6 +76,10 @@ export function VitePluginDoubleshot(userConfig: Partial<VitePluginDoubleshotCon
await configureForMode(resolvedConfig)
},
configureServer(server) {
// only in development mode to set rendererUrl
if (viteMode !== 'development')
return

const { until, done } = useUntil(10 * 1000) // 10s timeout
const printUrls = server.printUrls.bind(server)
// override printUrls to get rendererUrl
Expand Down

0 comments on commit fa9a58f

Please sign in to comment.