Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit feb4e16

Browse files
committed
fix: fix pages dir missing fatal (#207)
1 parent c1ce7f9 commit feb4e16

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

server/app.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,6 @@ export class Application implements ServerApplication {
201201
}
202202
}
203203

204-
// update page routing
205-
const pagesDir = join(this.srcDir, 'pages')
206204
const walkOptions = {
207205
includeDirs: false,
208206
skip: [
@@ -211,19 +209,24 @@ export class Application implements ServerApplication {
211209
/(\.|_)(test|spec|e2e)\.(tsx?|jsx?|mjs)?$/i
212210
]
213211
}
214-
for await (const { path: p } of walk(pagesDir, walkOptions)) {
215-
const url = util.cleanPath('/pages/' + util.trimPrefix(p, pagesDir))
216-
let validated = moduleExts.some(ext => p.endsWith('.' + ext))
217-
if (!validated) {
218-
validated = this.config.plugins.some(p => p.type === 'loader' && p.test.test(url) && p.asPage)
219-
}
220-
if (validated) {
221-
await this.compile(url)
222-
this.#pageRouting.update(this.createRouteModule(url))
212+
213+
// load page routing
214+
const pagesDir = join(this.srcDir, 'pages')
215+
if (existsDirSync(pagesDir)) {
216+
for await (const { path: p } of walk(pagesDir, walkOptions)) {
217+
const url = util.cleanPath('/pages/' + util.trimPrefix(p, pagesDir))
218+
let validated = moduleExts.some(ext => p.endsWith('.' + ext))
219+
if (!validated) {
220+
validated = this.config.plugins.some(p => p.type === 'loader' && p.test.test(url) && p.asPage)
221+
}
222+
if (validated) {
223+
await this.compile(url)
224+
this.#pageRouting.update(this.createRouteModule(url))
225+
}
223226
}
224227
}
225228

226-
// update api routing
229+
// load api routing
227230
const apiDir = join(this.srcDir, 'api')
228231
if (existsDirSync(apiDir)) {
229232
for await (const { path: p } of walk(apiDir, { ...walkOptions, exts: moduleExts })) {

0 commit comments

Comments
 (0)