building with --base ""
results in /0
being used for the base instead
#14204
Labels
--base ""
results in /0
being used for the base instead
#14204
Describe the bug
Overview
When doing
vite build --base ""
, the resulting SPA loader has/0/
for all of it'shref
s andsrc
s.Expected behaviour
the resulting SPA loader has a base path of
/
for all of it'shref
s andsrc
s.Experienced Behaviour
the resulting SPA loader has a base path of
/0/
for all of it'shref
s andsrc
s.What I'm trying to do
I use
actions/configure-pages@v3
which provides environment information for the workflow, such as the base path for the deployment.It allows me to avoid specifying the base path in code as it is simply specified at deploy time in the build command like this:
However, when deploying to a root base,
configure-pages
returns the base path as blank and not/
, which is allowed as specified in the docs.This results in a broken build as the SPA loader tries to load assets from
domain.tld/0/assets/index-hash.js
instead ofdomain.tld/assets/index-hash.js
Triaging I have done
Only affects
vite@^4.3.0
as any older versions would error out when using--base ""
Only affects plain Vite projects, as I have successfully deployed a SvelteKit app using
vite build --base ""
(Vite 4.4.9)(I tried with vite.new/vue, vite.new/svelte, vite.new/solid)
Reproduction
https://stackblitz.com/edit/vitejs-vite-gqpqgr?file=dist%2Findex.html
Steps to reproduce
Run
npm i
followed bynpx vite build --base ""
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: