title: How to load a service worker using Webpack 5?
body: <p>I'm using Webpack 5 and I want to have a Service Worker that will intercept fetch requests and return responses locally without hitting the network. I also want to be able to import npm modules within the Service Worker. I used to use a library called <em>serviceworker-webpack-plugin</em> for this purpose, but it's no longer maintained, (and throws errors when I use it). The Webpack docs recommend using Workbox, but this seems to be just for caching assets in the Service Worker, as far as I can gather.
  Could someone tell me what the correct approach is in 2020 for creating a Service Worker with Webpack 5?</p>