refactor: config prop rename serviceWorkerPath -> path

This commit is contained in:
Ayo Ayco 2024-08-03 01:10:00 +02:00
parent ea673e6bdd
commit 881c946a0a
2 changed files with 5 additions and 5 deletions

View file

@ -10,8 +10,8 @@ export default defineConfig({
}), }),
integrations: [ integrations: [
serviceWorker({ serviceWorker({
path: "./src/utils/sw.js",
assetCachePrefix: 'cozy-reader', assetCachePrefix: 'cozy-reader',
serviceWorkerPath: './src/utils/sw.js'
}) })
] ]
}); });

View file

@ -9,7 +9,7 @@ let assets: string[] = [];
export type ServiceWorkerConfig = { export type ServiceWorkerConfig = {
assetCachePrefix?: string, assetCachePrefix?: string,
assetCacheVersionID?: string, assetCacheVersionID?: string,
serviceWorkerPath: string, path: string,
} }
const plugin_dir = path.resolve(path.dirname('.')); const plugin_dir = path.resolve(path.dirname('.'));
@ -18,7 +18,7 @@ export default (config: ServiceWorkerConfig): AstroIntegration => {
let { let {
assetCachePrefix, assetCachePrefix,
assetCacheVersionID = randomUUID(), assetCacheVersionID = randomUUID(),
serviceWorkerPath path: serviceWorkerPath
} = config; } = config;
console.log('[astro-sw] dir', plugin_dir) console.log('[astro-sw] dir', plugin_dir)
@ -34,7 +34,7 @@ export default (config: ServiceWorkerConfig): AstroIntegration => {
let originalScript; let originalScript;
try { try {
const __dirname = path.resolve(path.dirname('.')); 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); console.log('[astro-sw] Using service worker:', swPath);
originalScript = await readFile(swPath); originalScript = await readFile(swPath);
} catch { } catch {