Files
codecraft/web/vite.config.ts
T
Richard ZinkandClaude Opus 5.5 10d4b64289 Add incoming webhooks, fix stale service worker and push re-registration
- Webhooks for automations: per-job secret, Gitea/GitHub HMAC signatures,
  payload appended to the instructions; settings on the automations page
- Service worker gets a new file name per build (proxies that cache *.js
  served a stale worker, which broke updates and Android installation);
  /sw.js is a kill switch that removes old workers
- Push: devices re-register their subscription with the server on start and
  before a test; the test reports why a push service rejected a message

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 00:38:04 +01:00

60 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { VitePWA } from "vite-plugin-pwa";
const backend = process.env.CODECRAFT_BACKEND ?? "http://127.0.0.1:8787";
const BUILD_ID = Date.now().toString(36);
export default defineConfig({
plugins: [
react(),
VitePWA({
registerType: "autoUpdate",
// A new file name per build: reverse proxies with "cache assets" (e.g. Nginx
// Proxy Manager) cache *.js by URL – a stale service worker would break
// updates and installation. /sw.js is a kill switch for old installations.
filename: `sw-${BUILD_ID}.js`,
injectRegister: false,
includeAssets: ["icon.svg", "apple-touch-icon.png"],
manifest: {
name: "CodeCraft",
short_name: "CodeCraft",
description: "Web-based coding harness for AI models",
theme_color: "#282828",
background_color: "#282828",
display: "standalone",
start_url: "/",
id: "/",
scope: "/",
orientation: "any",
categories: ["developer", "productivity"],
icons: [
{ src: "icon-192.png", sizes: "192x192", type: "image/png" },
{ src: "icon-512.png", sizes: "512x512", type: "image/png" },
{ src: "icon-maskable-512.png", sizes: "512x512", type: "image/png", purpose: "maskable" },
{ src: "icon.svg", sizes: "any", type: "image/svg+xml" },
],
screenshots: [
{ src: "screenshots/wide.png", sizes: "1400x860", type: "image/png", form_factor: "wide", label: "Chat with an agent" },
{ src: "screenshots/narrow.png", sizes: "780x1688", type: "image/png", form_factor: "narrow", label: "CodeCraft on the phone" },
],
},
workbox: {
// The API is always live data; only the app shell is cached.
navigateFallbackDenylist: [/^\/api/, /^\/cli/],
runtimeCaching: [],
// The STEP importer (OpenCascade, ~8 MB) is loaded only when needed.
globIgnores: ["**/occt-import-js*", "**/screenshots/**", "sw.js"],
// Web Push handlers (push, notificationclick).
importScripts: ["push-sw.mjs"],
},
}),
],
server: {
proxy: {
"/api": { target: backend, ws: true, changeOrigin: true },
},
},
});