-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb82c63
commit fafbac0
Showing
23 changed files
with
88 additions
and
49 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineConfig, minimal2023Preset as preset } from '@vite-pwa/assets-generator/config'; | ||
|
||
export default defineConfig({ | ||
headLinkOptions: { | ||
preset: '2023', | ||
}, | ||
preset, | ||
images: ['public/notespace.png'], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
import { injectConfig } from './inject-config.ts'; | ||
//import { injectConfig } from './inject-config.ts'; | ||
import { manifestConfig } from './manifest-config.ts'; | ||
import { VitePWAOptions } from 'vite-plugin-pwa'; | ||
import { workboxConfig } from './workbox-config.ts'; | ||
|
||
export const pwaConfig: Partial<VitePWAOptions> = { | ||
mode: 'development', | ||
base: '/', | ||
strategies: 'injectManifest', | ||
srcDir: './src/pwa', | ||
filename: 'sw.ts', | ||
strategies: 'generateSW', | ||
//injectRegister: false, | ||
injectManifest: injectConfig, | ||
registerType: 'autoUpdate', | ||
//injectManifest: injectConfig, | ||
//registerType: 'prompt', | ||
manifest: manifestConfig, | ||
workbox: workboxConfig, | ||
devOptions: { | ||
enabled: true, | ||
navigateFallback: '../../index.html', | ||
navigateFallback: 'index.html', | ||
type: 'module', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
self.addEventListener('install', event => { | ||
console.log('Service worker installing...'); | ||
}); | ||
|
||
self.addEventListener('fetch', event => { | ||
console.log('Fetching:', event); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { GenerateSWOptions } from 'workbox-build'; | ||
|
||
export const workboxConfig: Partial<GenerateSWOptions> = { | ||
runtimeCaching: [ | ||
{ | ||
urlPattern: ({ url }) => url.pathname.startsWith('/'), | ||
handler: async ({ event }) => { | ||
console.log('Fetching:', event); | ||
try { | ||
const resp = await fetch(event.request); | ||
console.log('Fetched:', resp); | ||
return resp; | ||
} catch (error) { | ||
// Fetch failed, fetch from cache | ||
console.error('Error:', error); | ||
return caches.match(event.request); | ||
} | ||
}, | ||
options: { | ||
cacheName: 'app-cache', | ||
cacheableResponse: { statuses: [0, 200] }, | ||
}, | ||
}, | ||
// api calls to localhost:8080 | ||
{ | ||
urlPattern: ({ url }) => url.origin === 'http://localhost:8080', | ||
handler: async ({ event }) => { | ||
console.log('Fetching:', event); | ||
try { | ||
const resp = fetch(event.request); | ||
console.log('Fetched:', resp); | ||
return resp; | ||
} catch (error) { | ||
console.error('Error:', error); | ||
const cache = await caches.open('api-cache'); | ||
const cachedResponse = await cache.match(event.request); | ||
return cachedResponse; | ||
} | ||
}, | ||
options: { | ||
cacheName: 'api-cache', | ||
cacheableResponse: { statuses: [0, 200] }, | ||
expiration: { | ||
maxEntries: 10, | ||
maxAgeSeconds: 60, | ||
}, | ||
}, | ||
}, | ||
], | ||
//importScripts: ['./service-worker.ts'], | ||
//cleanupOutdatedCaches: true, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters