1

I'm using sw-precachevia create-react-app to enable my app for use offline. I have a video that is loaded via webpack, but I noticed that it is not included in the generated serviceWorker's precacheConfig array.

How can I force webpack / sw-precache to include the (hashed) video in the list of URLs to prefetch?

Raphael Rafatpanah
  • 19,082
  • 25
  • 92
  • 158
  • So you would like to cache the video in order to be playable in offline mode? – Matthew Barbara Sep 22 '17 at 21:35
  • @MatthewBarbara, Yes, but I can already do that if I play the complete video before going offline, or by `fetch`ing the video and saving the `blob` to `IndexedDB` and then doing something like `video.src = URL.createObjectURL(blob)`. I am specifically looking for a way to have the video added to the service worker's precache list to be able to know that everything, including the video, is cached once the service worker's `installed` event fires. Currently the `installed` event fires before the video is cached. – Raphael Rafatpanah Sep 22 '17 at 21:57
  • I'm not sure why the video isn't already included using `create-react-app`'s default set up. – Raphael Rafatpanah Sep 22 '17 at 21:57
  • I haven't seen your code but here is a working example of a working sw using video for offline use. https://googlechrome.github.io/samples/service-worker/prefetch-video/ – Matthew Barbara Sep 22 '17 at 22:09
  • Yes, I've seen this too. I'm wondering how that can be integrated with `create-react-app`'s setup (either ejected or not). – Raphael Rafatpanah Sep 22 '17 at 22:33

0 Answers0