vite-plugin-html
vite-plugin-html copied to clipboard
[Bug]plubic dir content rewrite to index.html
rewrites.push(createRewire('', indexPage, baseUrl, keys))
这条语句会把资源重定向到index.html。
插件server middlewares
执行早于vite 内置的servePublicMiddleware
,导致 public 没有被命中
server.middlewares.use(
history({
disableDotRule: undefined,
htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'],
rewrites: rewrites,
}),
)
if header.accept
includs 'text/html', 'application/xhtml+xml'
page will be rewrite. when i access file public/favicon.ico
, what is actually received header.accept
is accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9. so favicon.ico
reweire index.html
就是这个问题,导致我们一个项目死活静态文件无法直接用 url 查看,后来突然想到为什么我自己新建的一个 vite3 项目也有这个情况,然后一看,都有这个插件,终于找到源头 😅
vben admin 也有同样的问题,不知道官方是否有注意到此问题
最后怎么解决的 我访问本地html 文件 被重定向了