fix(bridge): respect custom app.html (#2339)

This commit is contained in:
Daniel Roe 2021-12-20 20:24:43 +00:00 committed by GitHub
parent 5ab18162dd
commit 279bfdc5b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,6 +43,14 @@ export function setupNitroBridge () {
nuxt.hook('close', () => nitroDevContext._internal.hooks.callHook('close')) nuxt.hook('close', () => nitroDevContext._internal.hooks.callHook('close'))
nitroDevContext._internal.hooks.hook('nitro:document', template => nuxt.callHook('nitro:document', template)) nitroDevContext._internal.hooks.hook('nitro:document', template => nuxt.callHook('nitro:document', template))
// Use custom document template if provided
if (nuxt.options.appTemplatePath) {
nuxt.hook('nitro:document', async (template) => {
template.src = nuxt.options.appTemplatePath
template.contents = await fsp.readFile(nuxt.options.appTemplatePath, 'utf-8')
})
}
// Expose process.env.NITRO_PRESET // Expose process.env.NITRO_PRESET
nuxt.options.env.NITRO_PRESET = nitroContext.preset nuxt.options.env.NITRO_PRESET = nitroContext.preset