-
diff --git a/config/pwa.ts b/config/pwa.ts
index 63ffc356..1eb7d7d0 100644
--- a/config/pwa.ts
+++ b/config/pwa.ts
@@ -3,7 +3,7 @@ import type { VitePWANuxtOptions } from '../modules/pwa/types'
const isPreview = process.env.PULL_REQUEST === 'true'
-const pwa: VitePWANuxtOptions = {
+export const pwa: VitePWANuxtOptions = {
mode: isCI ? 'production' : 'development',
// disable PWA only when in preview mode
disable: /* temporarily test in CI isPreview || */ (isDevelopment && process.env.VITE_DEV_PWA !== 'true'),
@@ -49,5 +49,3 @@ const pwa: VitePWANuxtOptions = {
type: 'module',
},
}
-
-export { pwa }
diff --git a/composables/pwa/index.ts b/plugins/pwa.client.ts
similarity index 81%
rename from composables/pwa/index.ts
rename to plugins/pwa.client.ts
index 95cacb65..1bc21afa 100644
--- a/composables/pwa/index.ts
+++ b/plugins/pwa.client.ts
@@ -1,6 +1,6 @@
import { useRegisterSW } from 'virtual:pwa-register/vue'
-export function usePWA() {
+export default defineNuxtPlugin(() => {
const online = useOnline()
const {
@@ -34,10 +34,12 @@ export function usePWA() {
}
return {
- needRefresh,
- updateServiceWorker,
- close,
+ provide: {
+ pwa: reactive({
+ needRefresh,
+ updateServiceWorker,
+ close,
+ }),
+ },
}
-}
-
-export const pwa = reactive(usePWA())
+})