Skip to content

Commit

Permalink
generate pwa manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
ubermanu committed Dec 22, 2023
1 parent db8a7d7 commit 67088cf
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 4 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@sveltejs/kit": "^2.0.6",
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"@ubermanu/prettier-config": "^3.2.0",
"@vite-pwa/sveltekit": "^0.3.0",
"animate.css": "^4.1.1",
"autoprefixer": "^10.4.16",
"postcss": "^8.4.32",
Expand All @@ -35,7 +36,8 @@
"tailwindcss": "^3.4.0",
"typescript": "^5.3.3",
"vite": "^5.0.10",
"vite-plugin-pwa": "^0.17.4"
"vite-plugin-pwa": "^0.17.4",
"workbox-window": "^7.0.0"
},
"prettier": "@ubermanu/prettier-config"
}
22 changes: 22 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "Audience",
"short_name": "Audience",
"description": "Crowd reaction soundboard",
"theme_color": "#ffffff",
"icons": [
{
"src": "android-chrome-192x192.png",
Expand Down
13 changes: 13 additions & 0 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
<script>
import '../app.postcss'
import { pwaInfo } from 'virtual:pwa-info'
import { onMount } from 'svelte'
onMount(async () => {
if (pwaInfo) {
const { registerSW } = await import('virtual:pwa-register')
registerSW({ immediate: true })
}
})
</script>

<svelte:head>
{@html pwaInfo?.webManifest.linkTag}
</svelte:head>

<slot />
2 changes: 2 additions & 0 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// <reference types="vite-plugin-pwa/client" />
/// <reference types="vite-plugin-pwa/info" />
5 changes: 3 additions & 2 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { sveltekit } from '@sveltejs/kit/vite'
import { SvelteKitPWA } from '@vite-pwa/sveltekit'
import { defineConfig } from 'vite'
import { VitePWA } from 'vite-plugin-pwa'
import manifest from './src/manifest.json'

export default defineConfig({
plugins: [
sveltekit(),
VitePWA({
SvelteKitPWA({
strategies: 'generateSW',
registerType: 'autoUpdate',
manifest,
}),
Expand Down

0 comments on commit 67088cf

Please sign in to comment.