I've been using vite-plugin-html-template to build multi page app with vite-plugin-mpa on Vite version 4.
Recently updated to Vite version 5 and found that it needs to set appType: 'mpa' on vite config to load a bundle file for each page.
Without the config pageName is not correctly found and falls back to index, which leads to every page loading a bundle file of index page.
Here req.url is .src/pages/test with Vite version 4. But with Vite version 5, it is /test without appType: 'mpa'.
|
let url = req.url |
|
const pageName = (() => { |
|
if (url === '/') { |
|
return 'index' |
|
} |
|
return url.match(new RegExp(`${options.pagesDir}/(.*)/`))?.[1] || 'index' |
|
})() |
I've been using vite-plugin-html-template to build multi page app with vite-plugin-mpa on Vite version 4.
Recently updated to Vite version 5 and found that it needs to set
appType: 'mpa'on vite config to load a bundle file for each page.Without the config
pageNameis not correctly found and falls back toindex, which leads to every page loading a bundle file of index page.Here
req.urlis.src/pages/testwith Vite version 4. But with Vite version 5, it is/testwithoutappType: 'mpa'.vite-plugin-html-template/src/index.ts
Lines 56 to 62 in 0a4b2d8