From 881c946a0a0558e0438cc5c5f2d1ae9c71b91f80 Mon Sep 17 00:00:00 2001 From: ayoayco Date: Sat, 3 Aug 2024 01:10:00 +0200 Subject: [PATCH] refactor: config prop rename serviceWorkerPath -> path --- astro.config.mjs | 2 +- src/plugins/astro-sw.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/astro.config.mjs b/astro.config.mjs index 30bc0dd..ddb46c6 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -10,8 +10,8 @@ export default defineConfig({ }), integrations: [ serviceWorker({ + path: "./src/utils/sw.js", assetCachePrefix: 'cozy-reader', - serviceWorkerPath: './src/utils/sw.js' }) ] }); \ No newline at end of file diff --git a/src/plugins/astro-sw.ts b/src/plugins/astro-sw.ts index ae47e5e..60b9de6 100644 --- a/src/plugins/astro-sw.ts +++ b/src/plugins/astro-sw.ts @@ -9,16 +9,16 @@ let assets: string[] = []; export type ServiceWorkerConfig = { assetCachePrefix?: string, assetCacheVersionID?: string, - serviceWorkerPath: string, + path: string, } const plugin_dir = path.resolve(path.dirname('.')); export default (config: ServiceWorkerConfig): AstroIntegration => { - let { + let { assetCachePrefix, assetCacheVersionID = randomUUID(), - serviceWorkerPath + path: serviceWorkerPath } = config; console.log('[astro-sw] dir', plugin_dir) @@ -34,7 +34,7 @@ export default (config: ServiceWorkerConfig): AstroIntegration => { let originalScript; try { const __dirname = path.resolve(path.dirname('.')); - const swPath = path.join(__dirname,serviceWorkerPath ?? ''); + const swPath = path.join(__dirname, serviceWorkerPath ?? ''); console.log('[astro-sw] Using service worker:', swPath); originalScript = await readFile(swPath); } catch {