diff --git a/public/manifest.webmanifest b/public/manifest.webmanifest index 48e88a4..6c62cc5 100644 --- a/public/manifest.webmanifest +++ b/public/manifest.webmanifest @@ -2,23 +2,23 @@ "name": "EdenText", "short_name": "EdenText", "description": "A word processor that runs in the browser and saves .odt and .docx. No account, no server: the document never leaves the machine.", - "id": "/", - "start_url": "/", - "scope": "/", + "id": "./", + "start_url": "./", + "scope": "./", "display": "standalone", "orientation": "any", "background_color": "#e6e9eb", "theme_color": "#52748b", "categories": ["productivity", "utilities"], "icons": [ - { "src": "/favicon.svg", "sizes": "any", "type": "image/svg+xml" }, - { "src": "/icon-192.png", "sizes": "192x192", "type": "image/png" }, - { "src": "/icon-512.png", "sizes": "512x512", "type": "image/png" }, - { "src": "/icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" } + { "src": "favicon.svg", "sizes": "any", "type": "image/svg+xml" }, + { "src": "icon-192.png", "sizes": "192x192", "type": "image/png" }, + { "src": "icon-512.png", "sizes": "512x512", "type": "image/png" }, + { "src": "icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" } ], "file_handlers": [ { - "action": "/", + "action": "./", "accept": { "application/vnd.oasis.opendocument.text": [".odt"], "application/vnd.oasis.opendocument.text-template": [".ott"], diff --git a/public/sw.js b/public/sw.js index 6a19174..13f6100 100644 --- a/public/sw.js +++ b/public/sw.js @@ -3,8 +3,9 @@ // fonts and the WASM speller included, each kept the first time it is asked for. const CACHE = 'edentext-v1'; -// The entry document under one key, whichever path asked for it. -const SHELL = '/'; +// The entry document under one key, whichever path asked for it. Relative, so it +// resolves against this script's own directory — the app root under any base path. +const SHELL = './'; // The build's asset names carry a content hash, and the entry document is the only // place they are written down — so reading them out of it precaches the shell with no @@ -15,8 +16,8 @@ async function precache(cache) { const response = await fetch(SHELL, { cache: 'reload' }); await cache.put(SHELL, response.clone()); const html = await response.text(); - const assets = [...html.matchAll(/(?:src|href)="(\/assets\/[^"]+)"/g)].map((m) => m[1]); - await cache.addAll([...new Set(assets), '/favicon.svg', '/manifest.webmanifest']); + const assets = [...html.matchAll(/(?:src|href)="(\.?\/assets\/[^"]+)"/g)].map((m) => m[1]); + await cache.addAll([...new Set(assets), './favicon.svg', './manifest.webmanifest']); } self.addEventListener('install', (event) => { diff --git a/src/App.svelte b/src/App.svelte index e998eda..29c986a 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -1130,7 +1130,7 @@
diff --git a/src/lib/components/AboutDialog.svelte b/src/lib/components/AboutDialog.svelte index 25f5cee..45f1efd 100644 --- a/src/lib/components/AboutDialog.svelte +++ b/src/lib/components/AboutDialog.svelte @@ -40,9 +40,9 @@ - + - +

{t().about.tagline}

diff --git a/src/lib/components/ribbon/Ribbon.svelte b/src/lib/components/ribbon/Ribbon.svelte index 800d2ea..85869ee 100644 --- a/src/lib/components/ribbon/Ribbon.svelte +++ b/src/lib/components/ribbon/Ribbon.svelte @@ -330,7 +330,7 @@
diff --git a/src/main.ts b/src/main.ts index f2fd437..51795dc 100644 --- a/src/main.ts +++ b/src/main.ts @@ -19,7 +19,7 @@ window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () // build over the one being edited. if (import.meta.env.PROD && 'serviceWorker' in navigator) { window.addEventListener('load', () => { - navigator.serviceWorker.register('/sw.js').catch(() => {}); + navigator.serviceWorker.register(`${import.meta.env.BASE_URL}sw.js`).catch(() => {}); }); } diff --git a/vite.config.ts b/vite.config.ts index cd2a766..d0556e4 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -4,6 +4,9 @@ import { svelte } from '@sveltejs/vite-plugin-svelte'; import pkg from './package.json' with { type: 'json' }; export default defineConfig({ + // Relative asset URLs, so the same build works at the domain root and under a + // subpath (GitHub Pages project site). sw.js and the manifest are relative too. + base: './', plugins: [svelte()], define: { __APP_VERSION__: JSON.stringify(pkg.version) }, // hunspell-asm's ESM chain calls CJS/UMD deps as functions that a bundler