Merge "Optionally disable service worker in zuul-web"

This commit is contained in:
Zuul 2018-10-12 16:10:34 +00:00 committed by Gerrit Code Review
commit 654328f568
2 changed files with 9 additions and 0 deletions

View File

@ -192,3 +192,7 @@ As long as `yarn`_ is installed, the installation of zuul will run
.. _React: https://reactjs.org/
.. _Patternfly: https://www.patternfly.org/
.. _create-react-app: https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md
In some cases there is the need to disable the service worker which does
advanced caching. In order to do that set the environment variable
``REACT_APP_DISABLE_SERVICE_WORKER=true`` during installation.

View File

@ -21,6 +21,11 @@ const isLocalhost = Boolean(
)
export default function register () {
if (process.env.REACT_APP_DISABLE_SERVICE_WORKER === 'true') {
console.log('Disabled service worker')
return
}
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)