import { defineConfig } from 'vite';
function pagesPlugin(userOptions) {
name: 'vite-plugin-pages',
async configResolved(config) {
userOptions.resolver = 'react'
ctx = new PageContext(userOptions, config.root)
ctx.setLogger(config.logger)
return ctx.options.resolver.getComputedRoutes(ctx)
configureServer(server) {
ctx.setupViteServer(server)
if (ctx.options.moduleIds.includes(id))
return `${MODULE_ID_VIRTUAL}?id=${id}`
if (routeBlockQueryRE.test(id))
return ROUTE_BLOCK_ID_VIRTUAL
if (moduleId === MODULE_ID_VIRTUAL && pageId && ctx.options.moduleIds.includes(pageId))
return ctx.resolveRoutes()
if (id === ROUTE_BLOCK_ID_VIRTUAL) {
code: 'export default {};',
// https://vitejs.dev/config/
export default defineConfig({