feat: use pwa virtual module (#138)

This commit is contained in:
Joaquín Sánchez 2023-04-22 00:46:13 +02:00 committed by GitHub
parent 221f4d8e3e
commit 3371cc4559
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View File

@ -10,11 +10,6 @@ import 'uno.css'
import { basePath, isElectron } from './env'
import routes from '~pages'
// disable local storage cache when there is PWA:
// we need to keep local storage when running dev server without PWA
if (!isElectron && PWA)
disableCache('all')
const app = createApp(App)
const router = createRouter({
@ -22,5 +17,15 @@ const router = createRouter({
routes,
})
if (!isElectron && PWA) {
// disable local storage cache when there is PWA:
// we need to keep local storage when running dev server without PWA
disableCache('all')
router.isReady().then(async () => {
const { registerSW } = await import('virtual:pwa-register')
registerSW({ immediate: true })
})
}
app.use(router)
app.mount('#app')

View File

@ -13,7 +13,8 @@
"forceConsistentCasingInFileNames": true,
"types": [
"vite/client",
"vite-plugin-pages/client"
"vite-plugin-pages/client",
"vite-plugin-pwa/client"
]
},
"exclude": [