Skip to content

Commit

Permalink
frontend/web: compile using relative base path instead of absolute
Browse files Browse the repository at this point in the history
The default value for `base` is `/`, resulting in

```
<script type="module" crossorigin src="/assets/index-98aa38f3.js"></script>
<link rel="stylesheet" href="/assets/index-f26e81d9.css">
```

in `frontends/web/build/index.html`. For embedded use, the vite docs
recommend using a relative path:

```
<script type="module" crossorigin src="./assets/index-98aa38f3.js"></script>
<link rel="stylesheet" href="./assets/index-f26e81d9.css">
```

For Qt and Android, this does not seem to make a difference. On iOS
however, the way that local assets are looked up, it has to be
relative.
  • Loading branch information
benma committed Dec 8, 2023
1 parent 5657567 commit 6e89f5c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions frontends/web/vite.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import checker from 'vite-plugin-checker';

export default defineConfig(() => {
return {
// Relative base path so the js/css files are referenced with `./index-...js` instead of
// `/index-...js`. This makes it easier to find these files in iOS.
base: './',
build: {
modulePreload: false,
outDir: 'build',
Expand Down

0 comments on commit 6e89f5c

Please sign in to comment.