feat: provide build end hook (#709)

Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
pull/973/head
Joaquín Sánchez 2 years ago committed by GitHub
parent 22006e8d6e
commit e0b730aa8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -87,5 +87,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.`)
}

@ -71,6 +71,12 @@ export interface UserConfig<ThemeConfig = any> {
* @default false
*/
ignoreDeadLinks?: boolean
/**
* Build end hook: called when SSG finish.
* @param siteConfig The resolved configuration.
*/
buildEnd?: (siteConfig: SiteConfig) => Promise<void>
}
export type RawConfigExports<ThemeConfig = any> =
@ -88,6 +94,7 @@ export interface SiteConfig<ThemeConfig = any>
| 'mpa'
| 'lastUpdated'
| 'ignoreDeadLinks'
| 'buildEnd'
> {
root: string
srcDir: string
@ -166,7 +173,8 @@ export async function resolveConfig(
vite: userConfig.vite,
shouldPreload: userConfig.shouldPreload,
mpa: !!userConfig.mpa,
ignoreDeadLinks: userConfig.ignoreDeadLinks
ignoreDeadLinks: userConfig.ignoreDeadLinks,
buildEnd: userConfig.buildEnd
}
return config

Loading…
Cancel
Save