fix(vite): use resolved nuxt template dst to invalidate modules

This commit is contained in:
Daniel Roe 2024-11-17 14:32:31 -05:00
parent 45824edeee
commit 595b960fda
No known key found for this signature in database
GPG Key ID: CBC814C393D93268

View File

@ -45,13 +45,13 @@ export function viteNodePlugin (ctx: ViteBuildContext): VitePlugin {
markInvalidate(mod) markInvalidate(mod)
} }
} }
for (const plugin of ctx.nuxt.options.plugins) {
markInvalidates(server.moduleGraph.getModulesByFile(typeof plugin === 'string' ? plugin : plugin.src)) if (ctx.nuxt.apps.default) {
} for (const template of ctx.nuxt.apps.default.templates) {
for (const template of ctx.nuxt.options.build.templates) {
markInvalidates(server.moduleGraph.getModulesByFile(template.dst!)) markInvalidates(server.moduleGraph.getModulesByFile(template.dst!))
} }
} }
}
server.middlewares.use('/__nuxt_vite_node__', toNodeListener(createViteNodeApp(ctx, invalidates))) server.middlewares.use('/__nuxt_vite_node__', toNodeListener(createViteNodeApp(ctx, invalidates)))