You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
routesDirectory treated differently in the vite-plugin and the router-generator #1240
I noticed that vite-plugin and the router generator use a different root when handling the routesDirectory from the router config.
Consider my vite root directory in /src/renderer. When I specify ./src/renderer/src/routes as my routesDirectory the vite-plugin is joining the path together with vite.root, when handling a hot update. This results in /src/renderer/src/renderer/src/routes.
On the other hand the router-generator is joining the path with the projects root directory. This results in /src/renderer/src/routes, which is correct. The problem is now, that either the vite plugin is watching the wrong directory or the generator can't find the right files.
Create a vite project with the vite config file at the project root.
Move the index.html and the src directory to ./ui
Specify root as ./ui in the vite config
Setup TanstackRouter with the vite plugin and routesDirectory: './ui'
Expected behavior
I expect that the routes gets processed properly and the vite plugin is detecting changes. The outcome is, that the routes gets generated at vite startup, but not when I do changes to the files.
Screenshots or Videos
No response
Platform
Not platform specific
Additional context
See packages/router-vite-plugin/src/index.ts at line 23
and packages/router-generator/src/generator.ts at line 136
You will notice, that the routes get generated on vite startup, but no changes to the files are recognized.
If you change the routesDirectory to .src/routes changes will be recognized, but the generator fails, cause it looks at the wrong path for the files.
It still doesn't work. n electron.vite.config.mjs if you specify the relative path of the settings: TanStackRouterVite({ routesDirectory: "./src/renderer/src/routes", generatedRouteTree: "./src/renderer/src/routeTree.gen.ts", }),
This also does not work when updating/adding/deleting files. But it works on startup. If you specify an absolute path, everything works. But I'm not sure if this is a good approach
Activity
linusrush commentedon Mar 4, 2024
Ran into the same problem while using electron-vite.
The vite config is in project root, but ui root is in "src/renderer".
The routesDirectory from router config is handled differently in vite-plugin and router-generator.
carl-sauter commentedon Mar 12, 2024
Any updates?
schiller-manuel commentedon Mar 13, 2024
can you please provide a complete example project where this issue is happening?
carl-sauter commentedon Mar 13, 2024
https://stackblitz.com/edit/github-k8oxxb
You will notice, that the routes get generated on vite startup, but no changes to the files are recognized.
If you change the
routesDirectoryto.src/routeschanges will be recognized, but the generator fails, cause it looks at the wrong path for the files.dmitrymaslov99 commentedon Apr 9, 2024
Any updates?
carl-sauter commentedon Apr 9, 2024
As you can see this was closed & the merge request was merged. So it should work now
dmitrymaslov99 commentedon Apr 9, 2024
It still doesn't work. n electron.vite.config.mjs if you specify the relative path of the settings:
TanStackRouterVite({ routesDirectory: "./src/renderer/src/routes", generatedRouteTree: "./src/renderer/src/routeTree.gen.ts", }),This also does not work when updating/adding/deleting files. But it works on startup. If you specify an absolute path, everything works. But I'm not sure if this is a good approach