feat: add plugin to unregister existing service workers on client
Build And Push Image / docker (push) Successful in 2m51s Details

This commit is contained in:
Matt 2025-08-07 13:07:51 +02:00
parent cbaedeb0a8
commit 989c56acbf
2 changed files with 20 additions and 94 deletions

View File

@ -14,7 +14,7 @@ export default defineNuxtConfig({
console.log(`🌐 Server listening on http://${host}:${port}`) console.log(`🌐 Server listening on http://${host}:${port}`)
} }
}, },
modules: ["vuetify-nuxt-module", "@vite-pwa/nuxt", "motion-v/nuxt"], modules: ["vuetify-nuxt-module", "motion-v/nuxt"],
app: { app: {
head: { head: {
titleTemplate: "%s • MonacoUSA Portal", titleTemplate: "%s • MonacoUSA Portal",
@ -33,99 +33,6 @@ export default defineNuxtConfig({
}, },
}, },
}, },
pwa: {
registerType: 'autoUpdate',
manifest: {
name: 'MonacoUSA Portal',
short_name: 'MonacoUSA',
description: 'MonacoUSA Portal - Unified dashboard for tools and services',
theme_color: '#a31515',
background_color: '#ffffff',
display: 'standalone',
orientation: 'portrait',
start_url: '/',
scope: '/',
icons: [
{
src: '/icons/icon-72x72.png',
sizes: '72x72',
type: 'image/png'
},
{
src: '/icons/icon-96x96.png',
sizes: '96x96',
type: 'image/png'
},
{
src: '/icons/icon-128x128.png',
sizes: '128x128',
type: 'image/png'
},
{
src: '/icons/icon-144x144.png',
sizes: '144x144',
type: 'image/png'
},
{
src: '/icons/icon-152x152.png',
sizes: '152x152',
type: 'image/png'
},
{
src: '/icons/icon-192x192.png',
sizes: '192x192',
type: 'image/png'
},
{
src: '/icons/icon-384x384.png',
sizes: '384x384',
type: 'image/png'
},
{
src: '/icons/icon-512x512.png',
sizes: '512x512',
type: 'image/png'
}
]
},
workbox: {
navigateFallback: '/',
globPatterns: ['**/*.{js,css,html,png,jpg,jpeg,svg,ico}'],
navigateFallbackDenylist: [
/^\/api\//,
/^\/auth\//,
/^\/login/,
/^\/dashboard/
],
runtimeCaching: [
{
urlPattern: /^https:\/\/.*\.monacousa\.org\/api\/.*/i,
handler: 'NetworkFirst',
options: {
cacheName: 'api-cache',
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 5 // 5 minutes for API calls
},
cacheableResponse: {
statuses: [0, 200]
}
}
}
],
skipWaiting: true,
clientsClaim: true,
cleanupOutdatedCaches: true
},
client: {
installPrompt: true,
periodicSyncForUpdates: 20
},
devOptions: {
enabled: true,
type: 'module'
}
},
nitro: { nitro: {
experimental: { experimental: {
wasm: true wasm: true

View File

@ -0,0 +1,19 @@
// Plugin to unregister any existing service workers
export default defineNuxtPlugin(async () => {
if (process.client && 'serviceWorker' in navigator) {
try {
const registrations = await navigator.serviceWorker.getRegistrations();
for (const registration of registrations) {
console.log('🧹 Unregistering service worker:', registration.scope);
await registration.unregister();
}
if (registrations.length > 0) {
console.log('✅ All service workers unregistered');
}
} catch (error) {
console.error('❌ Error unregistering service workers:', error);
}
}
});