if (nuxt.options.dev) {
const webManifest = `${nuxt.options.app.baseURL}${options.devOptions?.webManifestUrl ?? options.manifestFilename ?? 'manifest.webmanifest'}`
const devSw = `${nuxt.options.app.baseURL}dev-sw.js?dev-sw`
nuxt.hooks.hook('vite:serverCreated', (viteServer, { isClient }) => {
if (isClient) {
viteServer.middlewares.stack.push({
route: webManifest,
// @ts-expect-error just ignore
handle: (_req, _res, next) => {
next()
},
})
viteServer.middlewares.stack.push({
route: devSw,
// @ts-expect-error just ignore
handle: (_req, _res, next) => {
next()
},
})
}
})
}
if (nuxt.options.dev) {
const webManifest = `${nuxt.options.app.baseURL}${options.devOptions?.webManifestUrl ?? options.manifestFilename ?? 'manifest.webmanifest'}`
const devSw = `${nuxt.options.app.baseURL}dev-sw.js?dev-sw`
nuxt.hooks.hook('vite:serverCreated', (viteServer, { isClient }) => {
if (isClient) {
viteServer.middlewares.stack.push({
route: webManifest,
// @ts-expect-error just ignore
handle: (_req, _res, next) => {
next()
},
})
viteServer.middlewares.stack.push({
route: devSw,
// @ts-expect-error just ignore
handle: (_req, _res, next) => {
next()
},
})
}
})
}