d3e8df96ef
Validated on the strict 2018-2022 window and confirmed on the untouched 2022-2026 test set (RPS 0.1703 vs 0.1721 over 4,448 matches): - the Elo member now blends 30% of a 3x-faster Elo walk, so recent results move ratings much harder - ensemble weight shifts from 75/25 toward Elo to 45/55 toward the time-decayed Team-DC member — the recent-form model now leads - Team-DC refits nightly (and at boot) on the 15-year window plus every finished 2026 match, via a new committed-at-build dcTrain.json (server-only, excluded from the PWA precache) - a recent-form goal multiplier was also tested and did NOT validate; it ships disabled, and backtest.json records the whole decision buildBacktest.ts grew the experiment harness: wider xi/k grids, the fast-Elo and form variants, a pre-registered ship bar (>=0.0005 validation RPS), and a 7-day refit-cadence check. Older ratings.json files still work — all new model fields are optional with golden regression coverage. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
74 lines
2.6 KiB
TypeScript
74 lines
2.6 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import tailwindcss from '@tailwindcss/vite';
|
|
import { VitePWA } from 'vite-plugin-pwa';
|
|
import { fileURLToPath, URL } from 'node:url';
|
|
|
|
// Strict CSP injected at build time only (dev needs inline scripts for react-refresh).
|
|
// All external football APIs are called from the server, so the browser only ever
|
|
// talks to its own origin + WebSocket — connect-src can stay locked to 'self'.
|
|
const PROD_CSP =
|
|
"default-src 'self'; img-src 'self' data: blob:; style-src 'self' 'unsafe-inline'; " +
|
|
"script-src 'self'; connect-src 'self' ws: wss:; " +
|
|
"font-src 'self' data:; worker-src 'self' blob:; " +
|
|
"manifest-src 'self'; object-src 'none'; base-uri 'self'";
|
|
|
|
function cspPlugin() {
|
|
return {
|
|
name: 'inject-csp',
|
|
transformIndexHtml(html: string) {
|
|
const tag = `<meta http-equiv="Content-Security-Policy" content="${PROD_CSP}" />`;
|
|
return html.replace('<!--CSP-PLACEHOLDER-->', tag);
|
|
},
|
|
apply: 'build' as const,
|
|
};
|
|
}
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
react(),
|
|
tailwindcss(),
|
|
cspPlugin(),
|
|
VitePWA({
|
|
registerType: 'autoUpdate',
|
|
includeAssets: ['favicon.svg'],
|
|
manifest: {
|
|
name: 'Cup26 — World Cup 2026 Dashboard',
|
|
short_name: 'Cup26',
|
|
description: 'Live World Cup 2026 scores, model-driven odds, and data-story visualizations.',
|
|
theme_color: '#0a1410',
|
|
background_color: '#0a1410',
|
|
display: 'standalone',
|
|
icons: [
|
|
{ src: 'pwa-192x192.png', sizes: '192x192', type: 'image/png' },
|
|
{ src: 'pwa-512x512.png', sizes: '512x512', type: 'image/png' },
|
|
{ src: 'pwa-512x512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' },
|
|
],
|
|
},
|
|
workbox: {
|
|
globPatterns: ['**/*.{js,css,html,svg,png,woff2,json}'],
|
|
// server-only refit training data (~1MB) — keep it off every client
|
|
globIgnores: ['**/dcTrain.json'],
|
|
maximumFileSizeToCacheInBytes: 6 * 1024 * 1024,
|
|
skipWaiting: true,
|
|
clientsClaim: true,
|
|
cleanupOutdatedCaches: true,
|
|
// Live data is fetched fresh from /api; never serve it from the precache.
|
|
navigateFallbackDenylist: [/^\/api/, /^\/ws/],
|
|
},
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
},
|
|
},
|
|
server: {
|
|
// Dev: proxy API + WS to the Fastify server so the browser only talks to :5173.
|
|
proxy: {
|
|
'/api': { target: 'http://localhost:8787', changeOrigin: true },
|
|
'/ws': { target: 'ws://localhost:8787', ws: true },
|
|
},
|
|
},
|
|
});
|