@@ -7,6 +7,7 @@ import { writeFileSync } from 'fs';
77
88// Determine if we are in production mode
99const isProduction = process . env . NODE_ENV === 'production' ;
10+ const BASE_URL = process . env . VITE_BASE_URL || '/' ;
1011
1112export default {
1213 plugins : [
@@ -52,7 +53,7 @@ export default {
5253 ]
5354 } ) ,
5455 VitePWA ( {
55- base : isProduction ? '/flock/' : '/' ,
56+ base : BASE_URL ,
5657 registerType : 'autoUpdate' ,
5758 devOptions : {
5859 enabled : true
@@ -65,10 +66,9 @@ export default {
6566 description : 'Create 3D apps with blocks' ,
6667 theme_color : '#511d91' ,
6768 display : 'fullscreen' ,
68- start_url : isProduction ? '/flock/?fullscreen=true' : '/' ,
69- id : isProduction ? '/flock/?fullscreen=true' : '/' ,
70- scope : isProduction ? '/flock/' : '/' ,
71-
69+ start_url : isProduction ? BASE_URL + '?fullscreen=true' : '/' ,
70+ id : isProduction ? BASE_URL + '?fullscreen=true' : '/' ,
71+ scope : BASE_URL ,
7272 icons : [
7373 {
7474 src : 'images/icon_192x192.png' ,
@@ -88,7 +88,7 @@ export default {
8888 '**/*.{js,css,html,ico,png,svg,glb,gltf,ogg,mp3,aac,wasm,json,woff,woff2}' , // Precache all assets
8989 ] ,
9090 modifyURLPrefix : isProduction ? {
91- '' : '/flock/' , // Prepend the base URL to all cached assets in production
91+ '' : BASE_URL , // Prepend the base URL to all cached assets in production
9292 } : { } ,
9393 runtimeCaching : [
9494 {
@@ -105,7 +105,7 @@ export default {
105105 } ,
106106 {
107107 // Cache assets from GitHub Pages
108- urlPattern : new RegExp ( '^https://flipcomputing\\.github\\.io/flock/' ) ,
108+ urlPattern : ( { url } ) => url . origin === self . location . origin ,
109109 handler : 'CacheFirst' , // Cache GitHub-hosted assets
110110 options : {
111111 cacheName : 'github-pages-cache' ,
0 commit comments