First version of Karten App

This commit is contained in:
2026-10-09 04:20:40 +02:00
commit 83a36c7a22
41 changed files with 10834 additions and 0 deletions
+71
View File
@@ -0,0 +1,71 @@
import fs from "node:fs";
import path from "node:path";
import { defineConfig } from "vitest/config";
import { VitePWA } from "vite-plugin-pwa";
/** Drop the previous app build. Kacheln, icons, and the Übersicht stay. */
function replaceGeneratedApp() {
return {
name: "replace-generated-app",
apply: "build" as const,
buildStart() {
const outDir = path.resolve("public");
fs.rmSync(path.join(outDir, "assets"), { recursive: true, force: true });
for (const name of ["index.html", "sw.js", "manifest.webmanifest"]) {
fs.rmSync(path.join(outDir, name), { force: true });
}
if (!fs.existsSync(outDir)) return;
for (const name of fs.readdirSync(outDir)) {
if (name.startsWith("workbox-") && name.endsWith(".js")) {
fs.rmSync(path.join(outDir, name));
}
}
},
};
}
export default defineConfig({
plugins: [
replaceGeneratedApp(),
VitePWA({
registerType: "autoUpdate",
includeAssets: ["icon-192.png", "icon-512.png", "uebersicht.json"],
manifest: {
name: "Karte",
short_name: "Karte",
description: "DTK25-Karte für das Gelände",
lang: "de",
start_url: "/",
scope: "/",
display: "standalone",
background_color: "#e7e1d4",
theme_color: "#1e3328",
icons: [
{ src: "icon-192.png", sizes: "192x192", type: "image/png" },
{
src: "icon-512.png",
sizes: "512x512",
type: "image/png",
purpose: "any maskable",
},
],
},
workbox: {
// Top-level and assets/ only. A recursive glob would walk every Kachel.
globPatterns: ["*.{html,js,svg,woff2}", "assets/**/*.{js,css,woff2}"],
globIgnores: ["**/node_modules/**/*", "kacheln/**"],
navigateFallback: "index.html",
},
}),
],
build: {
outDir: "public",
emptyOutDir: false,
copyPublicDir: false,
},
test: {
environment: "node",
include: ["src/**/*.test.ts"],
globals: true,
},
});