Skip to content

Commit

Permalink
feat: support custom base
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Nov 21, 2022
1 parent c5b30fe commit de6b92a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/index.ts
Expand Up @@ -9,16 +9,16 @@ export interface ViteClient {
/**
* Get the module of `/@vite/client`
*/
export async function getViteClient(): Promise<ViteClient | undefined> {
export async function getViteClient(base = '/'): Promise<ViteClient | undefined> {
try {
return await import(/* @vite-ignore */ ['', '@vite', 'client'].join('/'))
return await import(/* @vite-ignore */ `${base}@vite/client`)
}
catch {}
return undefined
}

export async function createHotContext(path = '/____'): Promise<ViteHotContext | undefined> {
const viteClient = await getViteClient()
export async function createHotContext(path = '/____', base = '/'): Promise<ViteHotContext | undefined> {
const viteClient = await getViteClient(base)
return viteClient?.createHotContext(path)
}

Expand Down

0 comments on commit de6b92a

Please sign in to comment.