Skip to content

Commit eee169e

Browse files
committed
Fix PWA install
1 parent 653f716 commit eee169e

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

app/plugins/pwa.client.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default defineNuxtPlugin(() => {
2+
if ('serviceWorker' in navigator) {
3+
navigator.serviceWorker.register('/sw.js', { scope: '/' });
4+
}
5+
});
6+

nuxt.config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ export default defineNuxtConfig({
1212
],
1313

1414
pwa: {
15+
injectRegister: false,
1516
registerType: 'autoUpdate',
17+
includeAssets: ['favicon.ico', 'apple-touch-icon.png', 'safari-pinned-tab.svg'],
1618
manifest: {
19+
id: '/',
20+
start_url: '/',
21+
scope: '/',
1722
name: 'Showcode',
1823
short_name: 'Showcode',
1924
description: 'Create beautiful images of code.',
@@ -40,7 +45,7 @@ export default defineNuxtConfig({
4045
],
4146
},
4247
workbox: {
43-
navigateFallback: '/',
48+
navigateFallback: '/index.html',
4449
globPatterns: ['**/*.{js,css,html,png,svg,ico,woff2}'],
4550
globIgnores: ['**/*.worker-*.js'],
4651
maximumFileSizeToCacheInBytes: 5 * 1024 * 1024,
@@ -96,7 +101,9 @@ export default defineNuxtConfig({
96101
{ rel: 'icon', type: 'image/png', sizes: '16x16', href: '/favicon-16x16.png' },
97102
{ rel: 'apple-touch-icon', sizes: '180x180', href: '/apple-touch-icon.png' },
98103
{ rel: 'mask-icon', href: '/safari-pinned-tab.svg', color: '#5bbad5' },
104+
{ rel: 'manifest', href: '/manifest.webmanifest' },
99105
],
106+
100107
},
101108
},
102109
})

0 commit comments

Comments
 (0)