BionicFramework / BionicCLI

Bionic Framework CLI - Ionic Framework CLI clone to build and deploy PWAs and Mobile Apps using Blazor
MIT License
58 stars 4 forks source link

Automatically generate list of dependencies for PWAs service worker #11

Open bmsantos opened 6 years ago

bmsantos commented 6 years ago

List of dependencies must be generated to be used for caching by PWA service worker. This list must be tied with build method in order to provide an updated set of assets to be cahed. Must include versioning for service worker.

nickl- commented 2 years ago

This can be handled by dotnet build to generate the project's assets file, as per the ASP.NET Core Blazor Progressive Web Application (PWA) documentation page. Here is what you need...

Configuration

Add the following to the project file:

To render the assets add the following ServiceWorkerAssetsManifest property to a PropertyGroup

  ...
  <ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
</PropertyGroup>

To configure the development (non caching) and production service workers add the following ServiceWorker item to an ItemGroup

<ItemGroup>
  <ServiceWorker Include="wwwroot\service-worker.js" 
    PublishedContent="wwwroot\service-worker.published.js" />
</ItemGroup>

Required files

Download the following raw files from the documentation repository and place them in the wwwroot folder:

Implemention

Add the following to the app's wwwroot/index.html file:


<link href="manifest.json" rel="manifest" />
<link rel="apple-touch-icon" sizes="512x512" href="icon-512.png" />
<link rel="apple-touch-icon" sizes="192x192" href="icon-192.png" />
    ...
    <script>navigator.serviceWorker.register('service-worker.js');</script>
</body>