0

I would like to build my static HTML site in a DIST folder that works regardless of the directory that it's placed in. I am using Vite to build the project. I use base to tell Vite where the project is:

package.json:

    "scripts": {
        "dev": "vite",
        "build": "vite build --base=/~henk/projects/myproject/dist/"
    },

This works, but now my static website can only be opened while the project is exactly in localhost/~henk/projects/myproject/dist/

If I move the project files to another folder, it stops working. If I want to publish to github pages, I have to remember to manually change the base every time.

Is there a way to make Vite use relative paths?

Kokodoko
  • 26,167
  • 33
  • 120
  • 197
  • 2
    Does this answer your question? [vite build always using static paths](https://stackoverflow.com/questions/69744253/vite-build-always-using-static-paths) – KhalfaniW Apr 08 '23 at 20:09
  • 1
    Thanks, I missed that question even though I searched for it. Setting `--base='./'` works! – Kokodoko Apr 09 '23 at 08:01
  • @Kokodoko please answer this question yourself or set it as resolved in any other way – revelt Jul 10 '23 at 12:10

0 Answers0