In my app, when I do npm run dev I can test fine on http://localhost:3000
. But for the output build, where I run it, is part of another application sub folder. For example, the links ends up being like as I dump the dist output from the vite app into the reconstatus folder and to view the app I just go to
.html
. I noticed a problem where the generated code links to the js/css/etc...
set by vite start with a slash, so relative to the root, but this results in 404 can't find files, since now the files are in /docs/reconstatus
. Is there a way to tell vite, for build outputs, set the links to use a certain path like /docs/reconstatus
?
In my app, when I do npm run dev I can test fine on http://localhost:3000
. But for the output build, where I run it, is part of another application sub folder. For example, the links ends up being like http://myapp./docs/reconstatus
as I dump the dist output from the vite app into the reconstatus folder and to view the app I just go to http://myapp./docs/reconstatus/index.html
. I noticed a problem where the generated code links to the js/css/etc...
set by vite start with a slash, so relative to the root, but this results in 404 can't find files, since now the files are in /docs/reconstatus
. Is there a way to tell vite, for build outputs, set the links to use a certain path like /docs/reconstatus
?
- vitejs.dev/config/server-options.html#server-base maybe? – Arleigh Hix Commented Jun 9, 2023 at 19:11
1 Answer
Reset to default 6I assume you want to configure your public base path for your vite build. Tell me if i am wrong and i will edit the answer.
To configure the public build path pass it as a argument during the build process.
vite build --base=/my/public/path/
source: vite docs