Vite built to its relative dist folder
06:25 23 May 2024

I have started using Vite and everything works fine on dev but when doing build nothing displayed because it build to the root / which is a problem because I want to deploy it to a server as in https://example.com/iframes/app so I can then use an iframe to access this url.

So I have changed the vite.config.js to

base: './', // This will ensure that paths are relative to the current directory
build: {
  outDir: 'dist',
  assetsDir: 'assets',
},

This works for everything except for all the assets that were on public, on dev it's all fine but on build the browser looks for it at the root level of the server

`https://example.com/asset-on-public.svg`

instead of the desired

`https://example.com/iframes/app/asset-on-public.svg`

Any ideas?

javascript vite