feat: provide build end hook

pull/709/head
userquin 3 years ago
parent 0927a7393b
commit 19538283c8

@ -80,5 +80,7 @@ export async function build(
await fs.remove(siteConfig.tempDir)
}
await siteConfig.buildEnd?.(siteConfig)
console.log(`build complete in ${((Date.now() - start) / 1000).toFixed(2)}s.`)
}

@ -64,6 +64,12 @@ export interface UserConfig<ThemeConfig = any> {
* @experimental
*/
mpa?: boolean
/**
* Build end hook: called when SSG finish.
* @param siteConfig The resolved configuration.
*/
buildEnd?: (siteConfig: SiteConfig) => Promise<void>
}
export type RawConfigExports<ThemeConfig = any> =
@ -74,7 +80,7 @@ export type RawConfigExports<ThemeConfig = any> =
export interface SiteConfig<ThemeConfig = any>
extends Pick<
UserConfig,
'markdown' | 'vue' | 'vite' | 'shouldPreload' | 'mpa' | 'lastUpdated'
'markdown' | 'vue' | 'vite' | 'shouldPreload' | 'mpa' | 'lastUpdated' | 'buildEnd'
> {
root: string
srcDir: string
@ -152,7 +158,8 @@ export async function resolveConfig(
vue: userConfig.vue,
vite: userConfig.vite,
shouldPreload: userConfig.shouldPreload,
mpa: !!userConfig.mpa
mpa: !!userConfig.mpa,
buildEnd: userConfig.buildEnd
}
return config

Loading…
Cancel
Save