Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support hot reload if service worker is already registered #17

Open
seejamescode opened this issue Feb 21, 2017 · 0 comments
Open

Support hot reload if service worker is already registered #17

seejamescode opened this issue Feb 21, 2017 · 0 comments

Comments

@seejamescode
Copy link

If you happen to run your production server on localhost (to test the build), the service worker is registered as desired.

However, you the service worker then gets in the way of react-scripts start/yarn start's hot reloading.

I will make a PR recommending an edit to the HTML if statement that is working for us:

<script>
    if (
      'serviceWorker' in navigator &&
      window.location.hostname !== 'localhost'
    ) {
      window.addEventListener('load', function() {
        navigator.serviceWorker.register('/service-worker.js');
      });
    }
  </script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant