Skip to content

Commit

Permalink
FIX service worker path load
Browse files Browse the repository at this point in the history
  • Loading branch information
shajz committed Dec 29, 2022
1 parent 0b468d8 commit 6051ee0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ if (typeof global.process === 'undefined') {
// Start the mocking when each story is loaded.
// Repetitive calls to the `.start()` method do not register a new worker,
// but check whether there's an existing once, reusing it, if so.

const pathname = document.location.pathname.slice(0, document.location.pathname.lastIndexOf('/'));
worker.start({
serviceWorker: {
// Points to the custom location of the Service Worker file.

url: 'mockServiceWorker.js',
url: `${pathname}/mockServiceWorker.js`,
scope: '/',
},
});
Expand Down

0 comments on commit 6051ee0

Please sign in to comment.