diff --git a/Blazor.PWA.MSBuild.Tasks/Blazor.PWA.MSBuild.Tasks.csproj b/Blazor.PWA.MSBuild.Tasks/Blazor.PWA.MSBuild.Tasks.csproj index 51883d9..11be525 100644 --- a/Blazor.PWA.MSBuild.Tasks/Blazor.PWA.MSBuild.Tasks.csproj +++ b/Blazor.PWA.MSBuild.Tasks/Blazor.PWA.MSBuild.Tasks.csproj @@ -69,6 +69,7 @@ I will add more network caching strategies, but for now it has just one - cache + diff --git a/Blazor.PWA.MSBuild.Tasks/Templates/ServiceWorker/sw_fetch-none.template.js b/Blazor.PWA.MSBuild.Tasks/Templates/ServiceWorker/sw_fetch-none.template.js new file mode 100644 index 0000000..1eebf01 --- /dev/null +++ b/Blazor.PWA.MSBuild.Tasks/Templates/ServiceWorker/sw_fetch-none.template.js @@ -0,0 +1,3 @@ +self.addEventListener(networkFetchEvent, event => { + return fetch(event.request); +}); diff --git a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.Manifest.targets b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.Manifest.targets index eacd3d5..434766f 100644 --- a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.Manifest.targets +++ b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.Manifest.targets @@ -71,10 +71,11 @@ - $(WWWRoot)$(ServiceWorkerIndexUrl) + $(WWWRoot)$(ProjectIndexPage) + $(ProjectHomePage) $([System.IO.File]::ReadAllText($(IndexFile))) - + diff --git a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets index 2df8e04..fad73ec 100644 --- a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets +++ b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.ServiceWorker.targets @@ -48,9 +48,9 @@ - + const baseURL = '$(ServiceWorkerBaseURL)'%3B; - const indexURL = '$(ServiceWorkerBaseUrl)$(ServiceWorkerIndexURL)'%3B; + const indexURL = '$(ServiceWorkerBaseUrl)$(ProjectIndexPage)'%3B; const networkFetchEvent = '$(ServiceWorkerNetworkFetchEvent)'%3B; const swInstallEvent = '$(ServiceWorkerInstallEvent)'%3B; const swInstalledEvent = '$(ServiceWorkerInstalledEvent)'%3B; @@ -58,6 +58,16 @@ const staticCachePrefix = '$(ServiceWorkerCacheName)-v'%3B; const staticCacheName = '$(ServiceWorkerCacheName)-v$(ServiceWorkerCacheVersion)'%3B; + + + + const baseURL = '$(ServiceWorkerBaseURL)'%3B; + const indexURL = '$(ServiceWorkerBaseUrl)$(ProjectHomePage)'%3B; + const networkFetchEvent = '$(ServiceWorkerNetworkFetchEvent)'%3B; + const swInstallEvent = '$(ServiceWorkerInstallEvent)'%3B; + const swInstalledEvent = '$(ServiceWorkerInstalledEvent)'%3B; + const swActivateEvent = '$(ServiceWorkerActivateEvent)'%3B; + @@ -69,7 +79,7 @@ $(ServiceWorkerTemplatePath)sw_$(ServiceWorkerNetworkFetchEvent)-$(ServiceWorkerPattern).template.js - + @@ -92,10 +102,12 @@ - - - $(WWWRoot)$(ServiceWorkerIndexUrl) + $(WWWRoot)$(ProjectIndexPage) + $(ProjectHomePage) $([System.IO.File]::ReadAllText($(IndexFile))) diff --git a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.targets b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.targets index 019745f..6faef2f 100644 --- a/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.targets +++ b/Blazor.PWA.MSBuild.Tasks/build/BlazorPWA.MSBuild.targets @@ -4,16 +4,22 @@ + + + SSB + CSB + + ServiceWorker.js ServiceWorkerRegister.js - + + offline-first + none offline-first - - offline-first blazor-cache @@ -22,8 +28,11 @@ / - - index.html + + index.html + + + Pages/_Host.cshtml @@ -54,7 +63,7 @@ BeforeTargets="$(CreatePWABeforeTargets)" Condition="'$(ServiceWorkerPattern)'!='' AND '$(ServiceWorkerCacheName)'!='' AND '$(ServiceWorkerCacheVersion)'!='' AND (!Exists('$(WWWRoot)$(ServiceWorkerFileName)') OR '$(ServiceWorkerForce)'=='true')"> - +