feat: support debugging PWA in dev (#4853)

* feat: support enabling pwa in dev

* enable workbox debug

* add prebuild script

* fix lint
This commit is contained in:
David Luzar 2022-07-02 17:59:03 +02:00 committed by GitHub
parent bbfd2b3cd3
commit 0ef202f2df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 78 additions and 13 deletions

View file

@ -26,7 +26,11 @@ type Config = {
};
export const register = (config?: Config) => {
if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) {
if (
(process.env.NODE_ENV === "production" ||
process.env.REACT_APP_DEV_ENABLE_SW?.toLowerCase() === "true") &&
"serviceWorker" in navigator
) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) {