chore: use mjs for sw
This commit is contained in:
parent
f79e918606
commit
744067d211
2 changed files with 3 additions and 5 deletions
|
@ -17,7 +17,7 @@ export default defineConfig({
|
||||||
mdx(),
|
mdx(),
|
||||||
sitemap(),
|
sitemap(),
|
||||||
serviceWorker({
|
serviceWorker({
|
||||||
path: "./src/sw.ts",
|
path: "./src/sw.mjs",
|
||||||
assetCachePrefix: 'cozy-reader',
|
assetCachePrefix: 'cozy-reader',
|
||||||
assetCacheVersionID: VERSION,
|
assetCacheVersionID: VERSION,
|
||||||
logAssets: true,
|
logAssets: true,
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { logInfo } from './utils/logger'
|
||||||
* -- find usage in `astro.config.mjs` integrations
|
* -- find usage in `astro.config.mjs` integrations
|
||||||
* @see https://ayco.io/n/@ayco/astro-sw
|
* @see https://ayco.io/n/@ayco/astro-sw
|
||||||
*/
|
*/
|
||||||
const cacheName = `${__prefix ?? 'app'}-v${__version ?? '000'}`
|
const cacheName = `${__prefix ?? 'app'}-v${__version + '-' + Date.now()}`
|
||||||
const forceLogging = false;
|
const forceLogging = false;
|
||||||
|
|
||||||
const addResourcesToCache = async (resources) => {
|
const addResourcesToCache = async (resources) => {
|
||||||
|
@ -113,9 +113,7 @@ self.addEventListener('activate', (event) => {
|
||||||
self.addEventListener('install', (event) => {
|
self.addEventListener('install', (event) => {
|
||||||
logInfo('installing service worker...', { force: forceLogging, context: 'cozy-sw' })
|
logInfo('installing service worker...', { force: forceLogging, context: 'cozy-sw' })
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
addResourcesToCache([
|
addResourcesToCache(__assets ?? [])
|
||||||
...(__assets ?? [])
|
|
||||||
])
|
|
||||||
);
|
);
|
||||||
self.skipWaiting(); // activate updated SW
|
self.skipWaiting(); // activate updated SW
|
||||||
});
|
});
|
Loading…
Reference in a new issue