@@ -94,8 +94,9 @@ function pfeDevServerPlugin(options: PfeDevServerInternalConfig): Plugin {
9494 return {
9595 name : 'pfe-dev-server' ,
9696 async serverStart ( { fileWatcher, app } ) {
97- const { elementsDir, tagPrefix } = options ;
97+ const { elementsDir, tagPrefix, aliases } = options ;
9898 const { componentSubpath } = options . site ;
99+
99100 const router =
100101 new Router ( )
101102 . get ( / \/ p f - i c o n \/ i c o n s \/ .* \. j s $ / , ( ctx , next ) => {
@@ -109,21 +110,23 @@ function pfeDevServerPlugin(options: PfeDevServerInternalConfig): Plugin {
109110 // Redirect `components/jazz-hands/*.js` to `components/pf-jazz-hands/*.ts`
110111 . get ( `/${ componentSubpath } /:element/:fileName.js` , async ctx => {
111112 const { element, fileName } = ctx . params ;
112- ctx . redirect ( `/${ elementsDir } /${ element } /${ fileName } .ts` ) ;
113+ const prefixedElement = deslugify ( element ) ;
114+
115+ ctx . redirect ( `/${ elementsDir } /${ prefixedElement } /${ fileName } .ts` ) ;
113116 } )
114117 // Redirect `elements/jazz-hands/*.js` to `elements/pf-jazz-hands/*.ts`
115118 . get ( `/${ elementsDir } /:element/:fileName.js` , async ctx => {
116119 const { element, fileName } = ctx . params ;
117- ctx . redirect ( `/${ elementsDir } /${ element } /${ fileName } .ts` ) ;
120+ const prefixedElement = deslugify ( element ) ;
121+
122+ ctx . redirect ( `/${ elementsDir } /${ prefixedElement } /${ fileName } .ts` ) ;
118123 } )
119124 // Redirect `components/pf-jazz-hands|jazz-hands/demo/*-lightdom.css` to `components/pf-jazz-hands/*-lightdom.css`
120125 // Redirect `components/jazz-hands/demo/*.js|css` to `components/pf-jazz-hands/demo/*.js|css`
121126 . get ( `/${ componentSubpath } /:element/demo/:demoSubDir?/:fileName.:ext` , async ( ctx , next ) => {
122127 const { element, fileName, ext } = ctx . params ;
123- let prefixedElement = element ;
124- if ( ! element . includes ( tagPrefix ) ) {
125- prefixedElement = `${ tagPrefix } -${ element } ` ;
126- }
128+ const prefixedElement = deslugify ( element ) ;
129+
127130 if ( fileName . includes ( '-lightdom' ) && ext === 'css' ) {
128131 ctx . redirect ( `/${ elementsDir } /${ prefixedElement } /${ fileName } .${ ext } ` ) ;
129132 } else if ( ! element . includes ( tagPrefix ) ) {
@@ -135,12 +138,14 @@ function pfeDevServerPlugin(options: PfeDevServerInternalConfig): Plugin {
135138 // Redirect `components/jazz-hands/*` to `components/pf-jazz-hands/*` for requests not previously handled
136139 . get ( `/${ componentSubpath } /:element/:splatPath*` , async ( ctx , next ) => {
137140 const { element, splatPath } = ctx . params ;
141+ const prefixedElement = deslugify ( element ) ;
142+
138143 if ( splatPath . includes ( 'demo' ) ) {
139144 /* if its the demo directory return */
140145 return next ( ) ;
141146 }
142147 if ( ! element . includes ( tagPrefix ) ) {
143- ctx . redirect ( `/${ elementsDir } /${ tagPrefix } - ${ element } /${ splatPath } ` ) ;
148+ ctx . redirect ( `/${ elementsDir } /${ prefixedElement } /${ splatPath } ` ) ;
144149 } else {
145150 return next ( ) ;
146151 }
0 commit comments