feat: add plugin to unregister existing service workers on client
Build And Push Image / docker (push) Successful in 2m51s
Details
Build And Push Image / docker (push) Successful in 2m51s
Details
This commit is contained in:
parent
cbaedeb0a8
commit
989c56acbf
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue