emosheeep / vite-plugin-virtual-mpa

Out-of-box MPA plugin for Vite, generate multiple entries using only one template.
https://stackblitz.com/~/github.com/emosheeep/vite-plugin-virtual-mpa
MIT License
113 stars 15 forks source link

feat: Add preview server's history fallback support. #26

Closed emosheeep closed 1 year ago

jiadesen commented 1 year ago

看懂了...相当于可以给 preview 服务指定一个首页,不过我觉得没必要😅,直接在 index.html 维护一些预览服务的入口不是更直接么...而且预览服务要贴合线上,包括访问路径,访问 http://localhost:5174/ 重定向到 http://localhost:5174/home.html 是不是有违直觉,而且如果多入口也一定要有一个总入口的话,为啥不直接使用 index.html

emosheeep commented 1 year ago

只是个例子,为了说明问题,实际使用大部分情况下不需要配置 previewRewrites

jiadesen commented 1 year ago

但是我建议明确配置 previewRewrites 时再启用 configurePreviewServer

emosheeep commented 1 year ago

为什么呢,默认配置不影响什么

emosheeep commented 1 year ago

就像你说的,就算配也不知道配什么,因为是多入口,实际访问的时候,都是直接输入地址的。想要达成的效果是:本地开发和预览共用同一份系统代理配置

jiadesen commented 1 year ago

如果不配置 previewRewrites,就使用 vite 默认服务吧,直接访问预览服务 http://localhost:5174/ 时也会有以下输出,可能会有人疑问,为啥给我往 index.html 重定向,而且默认 rewrites 会把所有无法访问的资源重定向到 index.html,这可能存在副作用

image
emosheeep commented 1 year ago

重定向到index.html是符合预期的呀,vite也会重定向到index.html。如果什么都不存在,页面会响应 Cannot GET /

emosheeep commented 1 year ago

rewrite重定向只会处理accept类型包含html的History fallback 请求,资源请求不会处理的。我们先这样吧,如果真的有用户反馈到这个问题再根据这个调整,目前感觉这个逻辑比较符合场景。就算有不符合逻辑的重定向,也可以通过配置规则优先执行来做

jiadesen commented 1 year ago

行吧,我是觉得增加新功能时非必要不干预...