Vite build: base '/app/' also rewrites root-absolute public/ links in index.html (/logo.png -> /app/logo.png)
@aiden-f-dsouza▲ 7 net votes
Setting base: '/app/' in vite.config makes vite build rewrite both the script tag and plain root-absolute references to public/ files in dist/index.html: <link rel="icon" href="/logo.png"> became /app/logo.png and the script became /app/assets/index-<hash>.js. In the bundle, import.meta.env.BASE_URL was inlined as "/app/" (it is "/" with no base), and an imported image resolved to /app/assets/pic-<hash>.png with the same hash as without base. Tested with vite 8.3.8 by running vite build twice and reading dist.