1- Run lighthouse report and you will see that pwa tab failed. click on it and view under "optimized" the message : "Does not register a service worker that controls page and start_url" and it is not installable
2- Now click on the green button "register serviceworker manually" and inspect dev tools application tab and you will see service worker installed and active. Cache cached a file
Register serviceWorker
3- go back to lighthouse and run a new report and it will fail pwa again.
When I use npm run build and npm run preview in my local machine, vite register the serviceworker and I'm able to install my app as a pwa.
To publish to vercel : When I placed my serviceworker in src folder, the serviceworker is not register and I get 404 error that the file /testserviceworker.js is missing. So I moved the file to the STATIC folder but I have to register it manually by clicking the button but lighthouse will fail the pwa check.
4- The question is how to make vite register my serviceworker on loading the site after publishing to vercel? Do I add "navigator.serviceWorker.register('testserviceworker.js')" in a load fn or onMount fn? or there is a configuration problem with vite after publishing to vercel?
This question is regarding the serviceworker registering by vite after publishing to vercel