Add Svelte web client and service worker
Mobile-first PWA: groups via key-in-fragment links, encrypted outbox and sync over SSE, all split modes, currencies with ECB rate prefill, photos, comments, history and rewind, stats, recurring expenses, CSV and backup, EN/CS, dark/light theme, Web Push decrypted in the service worker. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FYo6JSV1fDU1fm3LU77iF
This commit is contained in:
parent
f67add3660
commit
8fbbb4933e
53 changed files with 4558 additions and 37 deletions
35
apps/web/vite.sw.config.ts
Normal file
35
apps/web/vite.sw.config.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
// Second build step: the service worker, as one classic script at /sw.js
|
||||
// (module service workers aren't supported everywhere yet). It precaches
|
||||
// whatever the first step put in dist/, so this must run after it.
|
||||
import { createHash } from 'node:crypto';
|
||||
import { readdirSync, readFileSync, statSync } from 'node:fs';
|
||||
import { join, relative } from 'node:path';
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
const dist = join(import.meta.dirname, 'dist');
|
||||
|
||||
function listFiles(dir: string): string[] {
|
||||
return readdirSync(dir).flatMap((f) => {
|
||||
const p = join(dir, f);
|
||||
return statSync(p).isDirectory() ? listFiles(p) : [p];
|
||||
});
|
||||
}
|
||||
|
||||
const files = listFiles(dist)
|
||||
.map((p) => '/' + relative(dist, p).split('\\').join('/'))
|
||||
.filter((p) => p !== '/sw.js' && !p.endsWith('.map'));
|
||||
const hash = createHash('sha256');
|
||||
for (const f of files.sort()) hash.update(f).update(readFileSync(join(dist, f)));
|
||||
|
||||
export default defineConfig({
|
||||
define: {
|
||||
__PRECACHE__: JSON.stringify(files),
|
||||
__VERSION__: JSON.stringify(hash.digest('hex').slice(0, 12)),
|
||||
},
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
emptyOutDir: false,
|
||||
target: 'es2022',
|
||||
lib: { entry: 'src/sw.ts', formats: ['iife'], name: 'sw', fileName: () => 'sw.js' },
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue