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 fs.remove(siteConfig.tempDir)
} }
await siteConfig.buildEnd?.(siteConfig)
console.log(`build complete in ${((Date.now() - start) / 1000).toFixed(2)}s.`) console.log(`build complete in ${((Date.now() - start) / 1000).toFixed(2)}s.`)
} }

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

Loading…
Cancel
Save