Unable to remove service worker from Expo?

Is there a way to disable the service worker that’s automatically created with Expo web?

I’m running into some frustrating issues in production where the service worker is caching assets that have since been deleted.

I’ve tried setting expo.web.build.properties.serviceWorker to false in the app.json, but that didn’t seem to have any effect. Because it’s not possible to put regular expressions into the JSON file, it seems like you’re not able to list regular expressions, so my effort to set expo.web.build.properties.serviceWorker.exclude to /.*/(based on Workbox’s GenerateSWOptions) was unsuccessful. Any tips?

Resources:

  • expo-cli schema (search for serviceWorker)
  • withWorkbox.ts, which seems to be the code that parses the configuration and passes it to the actual Workbox module

maybe you could try running expo customize:web, creating a new index.html file, and then removing the part where it registers the service worker?

https://docs.expo.io/versions/v36.0.0/guides/customizing-webpack/

1 Like

Looks like this worked! Thanks a lot for the help jmensch!

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.