Skip to content

Commit

Permalink
feat(#231): add external service-worker in condition where VITE_EXTER…
Browse files Browse the repository at this point in the history
…NAL_RESOURCES_URL is defined (#252)

fix: #231
  • Loading branch information
laurentC35 authored and QRuhier committed Oct 17, 2024
1 parent b3dcd48 commit c65c4a3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions drama-queen/src/queen-service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,27 @@ importScripts(
'https://storage.googleapis.com/workbox-cdn/releases/7.1.0/workbox-sw.js'
)

/**
* Load all functions needed by all service-workers
*/
const { CacheableResponsePlugin } = workbox.cacheableResponse
const { registerRoute } = workbox.routing
const { NetworkFirst, CacheFirst } = workbox.strategies
const { RangeRequestsPlugin } = workbox.rangeRequests

/**
* Load env variable with swEnv.js (manage by vite-envs plugin)
*/
importScripts(`${self._DRAMAQUEEN_URL}/swEnv.js`)

/**
* Load external resource service-worker
*/
if (self.__VITE_ENVS.VITE_EXTERNAL_RESOURCES_URL) {
// In external service-worker, self._QUEEN_CAPMI_URL has to be defined to get root url of externalResourcesUrl
self._QUEEN_CAPMI_URL = self.__VITE_ENVS.VITE_EXTERNAL_RESOURCES_URL
importScripts(`${self._QUEEN_CAPMI_URL}/queen-service-worker.js`)
}

const getDramaQueenUrlRegex = (url) => {
return url
Expand Down

0 comments on commit c65c4a3

Please sign in to comment.