Closed MJRT closed 6 months ago
You can custom your path by edit vite.config.ts. Like this.
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import generouted from '@generouted/react-router/plugin'
export default defineConfig({
plugins: [
react(),
generouted({
source: { routes: './client/src/pages/**/[\\w[-]*.{jsx,tsx}', modals: './client/src/pages/**/[+]*.{jsx,tsx}' },
output: './client/src/router.ts',
}),
],
resolve: { alias: { '@': '/client/src' } },
})
hi @VriskaSerket51, thanks your information, but it still has some trouble after trying to follow this example. The scanned path is not expected.
I think that path should like these.
export type Path =
| `/`
| `/engagements/:id/edit`
| `/hello`;
@MJRT Right now, the convention requires you to declare the routes inside of a src/pages
directory even in nested directory structure.
Could you try using app/frontend/src/pages
instead:
// vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import generouted from '@generouted/react-router/plugin'
export default defineConfig({
plugins: [
react(),
generouted({
source: {
routes: './app/frontend/src/pages/**/[\\w[-]*.{jsx,tsx}',
modals: './app/frontend/src/pages/**/[+]*.{jsx,tsx}'
},
output: './app/frontend/src/router.ts',
}),
],
resolve: { alias: { '@': '/app/frontend/src' } },
})
You'll likely also need to add a custom app/frontend/src/routes.tsx
file for the runtime glob to pick up your routes.
You can find all steps needed for using generouted
in a custom directory structure: examples/react-router-custom-path
@oedotme I get it. Thank you.
Hi, I'm trying to use it in ruby on rails framework via ruby-vite, but it's not working and show:
Maybe the reason is the path is hard coded, and I didn't find any way to change it.
My project can use react-router normally, and the structure is followd, all react or typescript file in![PixPin_2024-02-24_17-45-38](https://github.com/oedotme/generouted/assets/17826582/611f20b6-a648-40cd-82b8-098b91d9467d)
./app/frontend
:I would like to know how can I setting entry is
./app/frontend
instead of./src/