Skip to content

Commit

Permalink
Allow Modification of Service Worker Configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
RehanSaeed authored Nov 19, 2021
1 parent 0a2f3c8 commit 8f45dc8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/files/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const createServiceWorker = async (context, config, queue, options) => {
if (options.disableServiceWorker) return false;
const serviceWorkerPath = path.join(config.outputDir, options.serviceWorkerPath)

await generateSW({
const swConfig = {
modifyURLPrefix: { '' : config.pathPrefix + '/' || ''},
swDest: serviceWorkerPath,
globDirectory: config.outputDir,
Expand All @@ -30,7 +30,11 @@ export const createServiceWorker = async (context, config, queue, options) => {

return urls
}, {})
})
};
if (config.modifyServiceWorkerConfig) {
config.modifyServiceWorkerConfig(swConfig);
}
await generateSW(swConfig);

await appendToServiceWorker(config, options);
return true;
Expand Down

0 comments on commit 8f45dc8

Please # to comment.