fsbolero / Template

dotnet cli template to create Bolero applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PWA support

zakaluka opened this issue · comments

Hello,

This is a continuation of a conversation on the F# slack regarding PWA support for FSBolero.

I created 2 minimal projects with Blazor to understand the difference between templates with the PWA option -p enabled and disabled. Here is the diff output from comparing the two directories:

--- ~/t » diff --color --recursive nopwa pwa
diff --color --recursive nopwa/Properties/launchSettings.json pwa/Properties/launchSettings.json
6,7c6,7
<       "applicationUrl": "http://localhost:45259",
<       "sslPort": 44309
---
>       "applicationUrl": "http://localhost:20322",
>       "sslPort": 44320
diff --color --recursive nopwa/pwa.csproj pwa/pwa.csproj
5a6
>     <ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
12a14,17
>   </ItemGroup>
> 
>   <ItemGroup>
>     <ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
Only in pwa/wwwroot: icon-512.png
diff --color --recursive nopwa/wwwroot/index.html pwa/wwwroot/index.html
10a11,12
>     <link href="manifest.json" rel="manifest" />
>     <link rel="apple-touch-icon" sizes="512x512" href="icon-512.png" />
21a24
>     <script>navigator.serviceWorker.register('service-worker.js');</script>
Only in pwa/wwwroot: manifest.json
Only in pwa/wwwroot: service-worker.js
Only in pwa/wwwroot: service-worker.published.js

The difference in launchSettings.json can be ignored. However, looks like the remaining changes would be required.

Unfortunately, I have almost no experience with Bolero and no experience at all with .NET templates. If someone can help guide, I'm happy to take a crack at a PR.

Tested the PWA-related changes, and they seem to work for FSBolero also.

Github: https://github.com/zakaluka/test-pwa/
Test site: https://zakaluka.github.io/test-pwa/

Does this seem reasonable to integrate into the template?

Awesome! Feel free to send a PR 🙂

@Tarmil Will do. My original test was done by directly modifying a project, so I will do my best to retrofit the changes into the template.

@Tarmil some questions have come up as I'm modifying the template:

  1. Adding a new option pwa. Is this okay? Should it be called something else?
  2. When should the option take effect? I.e., does it need to be dependent on the values of server, minimal, razor, html, etc.?

pwa sounds good as an option name, especially since it's the same name used by the Blazor template.

I don't think there's any restriction in terms of when it can be used, it should be available regardless of the other options.

#22 created for this issue.

Closing this issue as the PR has now been merged. Thanks for all the help @Tarmil