Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Debugging ServiceWorkers#1689

Answeredbyseansaleh
seansaleh asked this question inQ&A
Discussion options

How would I go about debugging Service Workers?

I've tried to find some ways to set workbox to be in debug mode, but I can't find anything that works.
When I donpm run build and thennpm run serve the service worker doesn't seem debuggable.

Thanks!

You must be logged in to vote

To debug your service worker you need to use the flag--sw when runningnpm run dev

In detail, you need to edit"dev": "preact watch --sw", in yourpackage.json

Then every time you change your service worker you should stop the dev server and rerun it. For good measure you should also create a new Incognito session to view your page.

Thanks to#955 and#1594 for the pointers!

Replies: 2 comments 2 replies

Comment options

When I donpm run build and thennpm run serve the service worker doesn't seem debuggable.

Well that is the production-like output, not really what you'd want to use when debugging.

Depending on what you're looking to debug, you can edit theInjectManifest plugin using yourpreact.config.js or create a custom service worker to use.

You must be logged in to vote
2 replies
@seansaleh
Comment options

Thanks! I was missing something fundamental here, and ended up solving it by adding--sw and usingnpm run dev (see my new answer)

@rschristian
Comment options

Ah, yep, should've mentioned that here. Sorry about that! Your answer is indeed the way to go.

Comment options

To debug your service worker you need to use the flag--sw when runningnpm run dev

In detail, you need to edit"dev": "preact watch --sw", in yourpackage.json

Then every time you change your service worker you should stop the dev server and rerun it. For good measure you should also create a new Incognito session to view your page.

Thanks to#955 and#1594 for the pointers!

You must be logged in to vote
0 replies
Answer selected byseansaleh
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@seansaleh@rschristian

[8]ページ先頭

©2009-2025 Movatter.jp