sql-mistermagoo / blazor.pwa.msbuild Goto Github PK
View Code? Open in Web Editor NEWAn MSBuild package which adds simple PWA functionality to Blazor client-side Apps
License: MIT License
An MSBuild package which adds simple PWA functionality to Blazor client-side Apps
License: MIT License
Unless I misunderstand and misconfigure the ServiceWorkerPreCacheExcludeFiles
and ServiceWorkerPreCacheExcludeReleaseFiles
, we can't explicitly add things to the requiredFiles
array that will be cached.
Being able to explicitly add resources can be helpful when your data comes from a some REST endpoint (e.g., a controller) and not from a static file, which I expect will be common in a real app.
EDIT: This can also be helpful for static assets used by other packages - they are not in the project folder so they won't be generated, but they need to be cached as well.
While I can edit the array myself, I must remember to edit it again after re-generating anything from the PWA infrastructure, which is error prone. I'd rather not add another js file of my own to try to add to the cache myself (this is my first touch with a PWA and I'll probably mess something up).
Hi,
first of all, thanks for the awesome work!
I'd love to be able to set the theme_color property for the manifest.json file. Maybe I just overlooked it in the code, but I didn't find any way to customize it. Admittedly it's just a cosmetic issue, but it would be nice to set a custom color.
Cheers!
David
Not sure if this is an improvement or is some config im missing.
how can i set to not replace only the ServiceWorkerRegister.js when ServiceWorkerForce is set to true?
The idea is to keep the cache control on build but customize the serviceworkerregister.js
Looking through your documentation, it sounds like I should be able to put the install button inside my app, but attempting to call await JSRuntime.InvokeAsync<object>("BlazorPWA.installPWA");
results in a WASM error: Microsoft.JSInterop.JSException: Could not find 'BlazorPWA' in 'window'.
I'm assuming I missed a step in there somewhere. I see the ServiceWorker.js and ServiceWorkerRegister.js, but nothing that contains installPWA.
Any pointers for getting the install to kick off from in Blazor, or is the banner the only option?
I created a property group like this:
<PropertyGroup>
<ServiceWorkerForce>true</ServiceWorkerForce>
</PropertyGroup>
But i still need to add
<PropertyGroup>
<ServiceWorkerForce>true</ServiceWorkerForce>
<ServiceWorkerCacheVersion>2</ServiceWorkerCacheVersion>
</PropertyGroup>
and update the cache version every time i want to add changes to the blazor project.
How can I always keep the build fresh so when I launch the app the service worker/cache version updates autmatically?
I've just taken the latest version to test and have used the default Blazor server side project to convert to a PWA. After deploying (via Azure), I can't get the counter button click event to work? Menu items work fine, is there something additional I need to do?
Thanks
My website has different paths (rather than different host names) depending on the build config, like:
I'm using ServiceWorkerBaseUrl
and ManifestBaseUrl
to set the base accordingly.
However, this only works once. Once the index.html
contains the manifest and service worker URLs, MSBuild no longer touches it:
Condition="'$(IndexLines.Contains($(ServiceWorkerRegisterFileName)))'=='false'"
This logic doesn't really work when switching between different URLs as described above.
Two possible approaches:
index.html
at all, but rather create an intermediary versionCondition
such that the edited line can still be updatedA suggestion is to use workbox in the generated service worker, which would easily allow incorporation of other types of cache strategies. Thanks
Is there any way to clear data so I get the banner back?
I installed the app using my computers google chrome installation.
Hi MisterMagoo,
Thanks for your package.
I know you stopped development on the package, but maybe you can answer me a question.
My server-side blazor pwa project uses identity. When i login to the page, the POST requests get send 2 times.
When i look at the developer options from the browser i see, that 1 time the POST is send from the form, and one time from ServiceWorker.
Do you know that problem?
Thanks and regards
Michael
Would it be possible to disable the creation of the pwa on localhost so i don't have to keep updating the version of clear cache every update i do?
I would like to be able to extend the generated service worker with some workbox backgroundsync configuration. What would be suggested way to extend the generated service worker?
Could there be a way by which the build process can take a specified .js file and merge it into the generated file?
Hi,
I'm trying to use Blazor.PWA.MSBuild with Bolero. It's not so easy and maybe you will think about adding support for Bolero?
In a demo app, I was able to install the PWA and it launched successfully.
Closing the PWA, and opening the blazor app again with F5 or directly typing the url does not redirect to the installed PWA. Is there a way to accomplish this?
Thanks!
Hi, on localhost everything it's work great, but after deploy release version on ubuntu server baner with install option dosn't appear. Please help :)
I can't get the PWA install option to work(does not show) when publishing the app to Azure
using web deploy.
It might be because these files creates error 404 on load:
"/css/open-iconic/FONT-LICENSE",
"/css/open-iconic/font/fonts/open-iconic.otf",
"/css/open-iconic/ICON-LICENSE",
"/css/open-iconic/README.md",
Is it possible to remove these files from the Service worker?
I added icon-192.png and icon-512.png to my wwwroot folder but they do not work on my iphone. They show up correctly on the desktop, so I belive the path to the images is not the case.
Hi,
I'm sure there must be a trivial explanation for this, but I can't find it.
I create a Blazor Web Assembly project from the template. Everything works as expected. I add the nuget, and again it all works fine and when I launch the application in IIS Express, I get the install banner in desktop Chrome, and I can install the application and run it from the desktop icon, etc. No problems at all.
Then I deploy the application to full IIS. The Blazor app downloads and runs as expected. However, the install banner doesn't appear. Looking in the Chrome dev-tools, in the console I get a message that the Service Worker was registered successfully and is controlling http://localhost. However, when I check the application tab, it lists the SW status as redundant. Reloading the page or deleting the SW always results in the same message, saying "uncaught exception in Promise, request failed".
I have searched the web and tried numerous things like custom HTTP headers, opening up permissions on inetpub to Full Control for Everyone, changing the user IIS is running under, using a valid SSL certificate (which shouldn't be necessary for localhost), etc. Always the same thing: the Blazor app downloads and runs correctly, the registration of the SW succeeds, but the status is redundant and stopped.
I have also fiddled with Chrome flags, but that would seem to be useless, since the only difference is running against IIS or Express.
Any idea what I am doing wrong?
Dave
Is this only for web assembly Blazor or also for the one that uses Signal-R and runs on server?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.