@@ -201,8 +201,6 @@ export class Application implements ServerApplication {
201
201
}
202
202
}
203
203
204
- // update page routing
205
- const pagesDir = join ( this . srcDir , 'pages' )
206
204
const walkOptions = {
207
205
includeDirs : false ,
208
206
skip : [
@@ -211,19 +209,24 @@ export class Application implements ServerApplication {
211
209
/ ( \. | _ ) ( t e s t | s p e c | e 2 e ) \. ( t s x ? | j s x ? | m j s ) ? $ / i
212
210
]
213
211
}
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
+ }
223
226
}
224
227
}
225
228
226
- // update api routing
229
+ // load api routing
227
230
const apiDir = join ( this . srcDir , 'api' )
228
231
if ( existsDirSync ( apiDir ) ) {
229
232
for await ( const { path : p } of walk ( apiDir , { ...walkOptions , exts : moduleExts } ) ) {
0 commit comments