Skip to content

Commit 3db4f61

Browse files
chore: wip
1 parent c1fdebc commit 3db4f61

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

storage/framework/api/dev.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,22 @@ async function watchFolders() {
140140
log.success(`Hot reloaded Controller: ${filename}`)
141141
}
142142
})
143+
144+
// Watch app/Middleware directory for hot reloading
145+
watch(path.appPath('Middleware'), { recursive: true }, (event: string, filename: string | null) => {
146+
if (filename === null)
147+
return
148+
149+
log.info(`Detected ${event} in app/Middleware/${filename}`)
150+
log.info('Invalidating module cache for Middleware...')
151+
152+
const middlewarePath = path.appPath(`Middleware/${filename}`)
153+
if (invalidateModuleCache(middlewarePath)) {
154+
// Update the global cache buster to force fresh imports
155+
Router.updateCacheBuster()
156+
log.success(`Hot reloaded Middleware: ${filename}`)
157+
}
158+
})
143159
}
144160

145161
// @ts-expect-error - somehow type is not recognized

0 commit comments

Comments
 (0)