File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,22 @@ async function watchFolders() {
140
140
log . success ( `Hot reloaded Controller: ${ filename } ` )
141
141
}
142
142
} )
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
+ } )
143
159
}
144
160
145
161
// @ts -expect-error - somehow type is not recognized
You can’t perform that action at this time.
0 commit comments