From 589b815dfff26b3c867a47a10238f6067f793e8a Mon Sep 17 00:00:00 2001 From: Matt Hillsdon Date: Wed, 29 May 2024 12:09:04 +0100 Subject: [PATCH] Tweak enablement; add cache id --- .github/workflows/build.yml | 4 ++-- vite.config.ts | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d5db8462f..f1d130bcc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,8 +24,8 @@ jobs: STAGING_CLOUDFRONT_DISTRIBUTION_ID: E2ELTBTA2OFPY2 REVIEW_CLOUDFRONT_DISTRIBUTION_ID: E3267W09ZJHQG9 VITE_FOUNDATION_BUILD: ${{ github.repository_owner == 'microbit-foundation' }} - # Optionally disable the PWA config (service worker and web manifest) - # DISABLE_PWA: '1' + # This feature is also controlled by a client-side feature flag that is disabled by default for the moment + FEATURE_PWA: ${{ github.repository_owner == 'microbit-foundation' }} steps: # Note: This workflow disables deployment steps and micro:bit branding installation on forks. diff --git a/vite.config.ts b/vite.config.ts index e0778bad3..2c49697fb 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -76,9 +76,17 @@ export default defineConfig(({ mode }) => { react(), svgr(), VitePWA({ - disable: process.env.DISABLE_PWA === "1", + disable: process.env.FEATURE_PWA === "true", registerType: "autoUpdate", workbox: { + cacheId: + // v3 vs beta should have distinct caches + // for the moment we do this for all review stages too but likely that's too much over time + process.env.STAGE === "PRODUCTION" || + process.env.STAGE === "STAGING" || + process.env.STAGE === "REVIEW" + ? process.env.BASE_URL.replaceAll("/", "") + "-" + : undefined, // Only precache language assets for the fallback language. // Cache other languages at runtime. globIgnores: [