File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
playground/spa/src/pages/user Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 1+ import { useParams } from 'react-router-dom' ;
2+
3+ export default function UserDetail ( ) {
4+ const { id } = useParams < { id : string } > ( ) ;
5+ return < div > user detail page: { id } </ div > ;
6+ }
Original file line number Diff line number Diff line change @@ -64,11 +64,13 @@ export function conventionalRoutes(userConfig?: UserConfig): Plugin {
6464 const assetsDir = viteConfig . build . assetsDir ;
6565
6666 // By default, "src/pages/a/b/index.js" and "src/pages/c/index.js"
67- // will have the same chunk name: "index", ant it's a little confusing.
67+ // will have the same chunk name: "index", and it's a little confusing.
6868 //
6969 // To avoid duplicate chunk names, we should custom the names here.
7070 // eg: src/pages/a/b/index.js -> page~a~b
7171 // src/pages/c/index.js -> page~c
72+ // src/pages/d/[id].js -> page~d~{id}
73+ // src/pages/e/[...all].js -> page~e~{all}
7274 if ( chunkInfo . isDynamicEntry && chunkInfo . facadeModuleId ) {
7375 const pageConfigItem = pagesService . checkPageFile (
7476 chunkInfo . facadeModuleId
@@ -86,6 +88,7 @@ export function conventionalRoutes(userConfig?: UserConfig): Plugin {
8688 const name = path
8789 . trimExt ( withBase )
8890 . replace ( / ^ ( .+ ) \/ ( i n d e x | R E A D M E ) / , '$1' ) // remove trailing /index or /README
91+ . replace ( / \[ (?: \. { 3 } ) ? ( .* ?) \] / g, '{$1}' ) // transform [id] or [...id] to {id}
8992 . split ( '/' )
9093 . filter ( Boolean ) // remove leading slash
9194 . join ( '~' ) ; // a/b/c -> a~b~c
You can’t perform that action at this time.
0 commit comments