Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Commit

Permalink
fix: generate manifest.json when ssr is disabled
Browse files Browse the repository at this point in the history
Closes #32
  • Loading branch information
kevinmarrec committed Sep 29, 2022
1 parent fd77f68 commit 8c52b11
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/parts/manifest/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { join } from 'pathe'
import { joinURL } from 'ufo'
import { useNuxt, addServerHandler } from '@nuxt/kit'
import { useNuxt, addServerHandler, addTemplate } from '@nuxt/kit'
import type { PWAContext } from '../../types'

export default (pwa: PWAContext) => {
Expand All @@ -9,10 +10,19 @@ export default (pwa: PWAContext) => {

nuxt.options.runtimeConfig.pwaManifest = pwa.manifest

addServerHandler({
route: '/manifest.json',
handler: pwa._resolver.resolve('./runtime/server/manifest')
})
if (nuxt.options.ssr) {
addServerHandler({
route: '/manifest.json',
handler: pwa._resolver.resolve('./runtime/server/manifest')
})
} else {
addTemplate({
filename: 'manifest.json',
getContents: () => JSON.stringify(pwa.manifest),
dst: join(pwa._buildDir, 'manifest.json'),
write: true
})
}

pwa._manifestMeta = {
rel: 'manifest',
Expand Down

0 comments on commit 8c52b11

Please sign in to comment.