I've found a solution, it has caveats but it works.
Only tested when build as a Single Page Application
First, edit svelte.config.js
as follows.
import adapter from '@sveltejs/adapter-static';
export default {
kit: {
adapter: adapter({
fallback: 'index.html',
}),
paths: {base: '/my-svelte-app'},
}
};
The good thing is that now, every Svelte-generated links are updated with /my-svelte-app
.
The bad thing is that every human-generated links are NOT updated.
You have to do it manually for every href
or src
using the $app/paths module
<script>
import { base } from '$app/paths';
export let title = 'Ninja gaming'
</script>
<div class="title">
<img src="{base}/gamepad.svg" alt="Site logo">
<h1>{title}</h1>
</div>
<nav class="crumbs">
<ul>
<li class="crumb"><a href="{base}/">Home</a></li>
<li class="crumb"><a href="{base}/guides">Guides</a></li>
<li class="crumb"><a href="{base}/about">About</a></li>
</ul>
</nav>
Hope it helps !
The following Vite config options will be overridden by SvelteKit: -base
– Nosegay