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

refactor(plugin): `configureServer` use injecting post middleware #37

Open jiadesen opened 1 year ago

jiadesen commented 1 year ago

35

主要包含以下更改:

  1. 通过注入后置中间件的方式重写 configureServer
  2. 删除 useHistoryFallbackMiddleware 的默认规则
emosheeep commented 1 year ago

为啥把默认规则删了呀🤔

jiadesen commented 1 year ago

参照 connect-history-api-fallback 重写了 configureServer 的重定向策略,确实比较麻烦,但是应该能完全避免影响 rewritespages 配置之外的请求;configurePreviewServer 里的暂时没处理,如果也按 configureServer 重写的话 connect-history-api-fallback 这个依赖就可以干掉了

jiadesen commented 1 year ago

为啥把默认规则删了呀

没删,作为全局变量在这里声明:

image

在这里赋值:

image

在这里使用:

image