diff --git a/packages/ts/file-router/src/vite-plugin.ts b/packages/ts/file-router/src/vite-plugin.ts index 0f2ab98762..b4701cdd64 100644 --- a/packages/ts/file-router/src/vite-plugin.ts +++ b/packages/ts/file-router/src/vite-plugin.ts @@ -112,7 +112,8 @@ export default function vitePluginFileSystemRouter({ }, transform(code, id): Promise | TransformResult { let modifiedCode = code; - if (id.startsWith(fileURLToPath(_viewsDir)) && !basename(id).startsWith('_')) { + const viewsDirUsingSlashes = fileURLToPath(_viewsDir).replaceAll('\\', '/'); + if (id.startsWith(viewsDirUsingSlashes) && !basename(id).startsWith('_')) { if (isDevMode) { // To enable HMR for route files with exported configurations, we need // to address a limitation in `react-refresh`. This library requires