web: use Service Worker in production

This commit is contained in:
NikolayRechkin 2019-12-13 10:19:03 +03:00
parent 4239a04932
commit 07e3cefb5c
2 changed files with 2 additions and 2 deletions

View File

@ -22,7 +22,7 @@ const isLocalhost = Boolean(
export function register(config) {
if ('serviceWorker' in navigator) {
if (process.env.NODE_ENV === 'production' && '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) {

View File

@ -21,7 +21,7 @@ const isLocalhost = Boolean(
);
export function register(config) {
if ('serviceWorker' in navigator) {
if (process.env.NODE_ENV === 'production' && '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) {