import path from "node:path"; import react from "@vitejs/plugin-react-swc"; import { VitePWA } from 'vite-plugin-pwa'; import { defineConfig } from "vitest/config"; // https://vitejs.dev/config/ export default defineConfig(({ mode }) => ({ base: mode === 'production' && process.env.GITHUB_ACTIONS ? '/zelo-news/' : '/', server: { host: "::", port: 8080, }, plugins: [ react(), VitePWA({ registerType: 'autoUpdate', includeAssets: ['icon.svg', 'icon-192.png', 'icon-512.png'], manifest: { name: 'zelo.news', short_name: 'zelo', description: 'Your Source for Decentralized News', theme_color: '#000000', background_color: '#ffffff', display: 'standalone', start_url: '/', icons: [ { src: '/icon-192.png', sizes: '192x192', type: 'image/png', purpose: 'any maskable' }, { src: '/icon-512.png', sizes: '512x512', type: 'image/png', purpose: 'any maskable' } ] }, workbox: { globPatterns: ['**/*.{js,css,html,ico,png,svg,woff,woff2}'], runtimeCaching: [ { urlPattern: /^https:\/\/.*\.(?:png|jpg|jpeg|svg|gif|webp)$/, handler: 'CacheFirst', options: { cacheName: 'images-cache', expiration: { maxEntries: 50, maxAgeSeconds: 30 * 24 * 60 * 60, // 30 days }, }, }, { urlPattern: /^(https|wss):\/\/.*/, handler: 'NetworkOnly', }, ], }, }), ], test: { globals: true, environment: 'jsdom', setupFiles: './src/test/setup.ts', onConsoleLog(log) { return !log.includes("React Router Future Flag Warning"); }, env: { DEBUG_PRINT_LIMIT: '0', // Suppress DOM output that exceeds AI context windows }, }, resolve: { alias: { "@": path.resolve(__dirname, "./src"), }, }, }));