Files
SlpSoftware/vite.config.ts
T

60 lines
1.9 KiB
TypeScript

/// <reference types="vitest/config" />
import { defineConfig, type Plugin } from 'vite';
import react from '@vitejs/plugin-react';
import { version } from './package.json';
// Preloads the latin display font (Archivo, used by the hero heading and the
// 2026 section) so it is requested with the HTML instead of after the CSS has
// been parsed. Build only: in dev the bundle is not available.
const preloadHeroFont = (): Plugin => ({
name: 'preload-hero-font',
transformIndexHtml: {
order: 'post',
handler(_html, ctx) {
if (!ctx.bundle) return [];
return Object.keys(ctx.bundle)
.filter((file) => /archivo-latin-wdth-normal-.*\.woff2$/.test(file))
.map((file) => ({
tag: 'link',
attrs: {
rel: 'preload',
as: 'font',
type: 'font/woff2',
href: `/${file}`,
crossorigin: '',
},
injectTo: 'head-prepend' as const,
}));
},
},
});
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), preloadHeroFont()],
define: {
// Injected at build time, used as the Sentry `release` tag (see src/main.tsx).
__APP_VERSION__: JSON.stringify(version),
},
server: {
proxy: {
// Mirrors the reverse-proxy Pi's "/sentry-tunnel" location (see
// nginx/reverse-proxy-nginx.conf.example) so the same tunnel path also
// works locally during `pnpm dev`, avoiding ad-blocker ERR_BLOCKED_BY_CLIENT
// errors when testing locally too (see src/main.tsx's Sentry.init tunnel option).
// LET OP: moet in sync blijven met de VITE_SENTRY_DSN uit .env.local.
'/sentry-tunnel': {
target: 'https://o4511795618185216.ingest.de.sentry.io',
changeOrigin: true,
rewrite: () => '/api/4511795622838352/envelope/',
},
},
},
test: {
environment: 'jsdom',
globals: true,
setupFiles: './src/test/setup.ts',
css: true,
},
});