From d57dc0beacc8e5d754d06110e9922c7a675448fb Mon Sep 17 00:00:00 2001 From: Papia Karmakar Date: Tue, 2 Jun 2026 21:42:23 +0530 Subject: [PATCH 1/2] Integrate PWA plugin into Vite configuration Added PWA support with configuration for caching and manifest. --- vite.config.ts | 56 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index f2366b89..91b2df61 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,11 +1,63 @@ import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' +import { VitePWA } from 'vite-plugin-pwa' // Import the PWA plugin export default defineConfig({ - plugins: [react()], + plugins: [ + react(), + // Add and configure the PWA plugin + VitePWA({ + registerType: 'autoUpdate', + includeAssets: ['favicon.ico', 'apple-touch-icon.png', 'mask-icon.svg'], + manifest: { + name: 'GitHub Tracker', + short_name: 'GitTracker', + description: 'Track your GitHub repository metrics and contributions seamlessly.', + theme_color: '#0d1117', + background_color: '#0d1117', + display: 'standalone', + orientation: 'portrait', + start_url: '/', + icons: [ + { + src: 'crl.png', + sizes: '192x192', + type: 'image/png', + purpose: 'any' + }, + { + src: 'crl.png', + sizes: '512x512', + type: 'image/png', + purpose: 'any' + } + ] + }, + workbox: { + globPatterns: ['**/*.{js,css,html,ico,png,svg}'], + runtimeCaching: [ + { + urlPattern: /^https:\/\/api\.github\.com\/.*/i, + handler: 'NetworkFirst', + options: { + cacheName: 'github-api-cache', + expiration: { + maxEntries: 50, + maxAgeSeconds: 60 * 60 * 24 + }, + cacheableResponse: { + statuses: [0, 200] + } + } + } + ] + } + }) + ], + // Your existing test configuration remains exactly the same test: { globals: true, environment: 'jsdom', setupFiles: './src/setupTests.ts', }, -}) \ No newline at end of file +}) From d1aeb1d73b61e541335703c3a19f5594dc07d71a Mon Sep 17 00:00:00 2001 From: Papia Karmakar Date: Tue, 2 Jun 2026 21:43:47 +0530 Subject: [PATCH 2/2] Register service worker for automatic updates Add service worker registration for PWA support. --- src/main.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.tsx b/src/main.tsx index 4c5b79dd..fc9953bf 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -4,6 +4,10 @@ import App from "./App.tsx"; import "./index.css"; import { BrowserRouter } from "react-router-dom"; import ThemeWrapper from "./context/ThemeContext.tsx"; +// Import the service worker registration from the virtual module +import { registerSW } from "virtual:pwa-register"; +// Register the service worker to handle automatic background updates +registerSW({ immediate: true }); createRoot(document.getElementById("root")!).render( @@ -13,4 +17,4 @@ createRoot(document.getElementById("root")!).render( -); \ No newline at end of file +);