Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

39 строки
1.3 KiB

  1. /**
  2. * Copyright (c) 2015-present, Facebook, Inc.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. 'use strict';
  8. module.exports = function createNoopServiceWorkerMiddleware() {
  9. return function noopServiceWorkerMiddleware(req, res, next) {
  10. if (req.url === '/service-worker.js') {
  11. res.setHeader('Content-Type', 'text/javascript');
  12. res.send(
  13. `// This service worker file is effectively a 'no-op' that will reset any
  14. // previous service worker registered for the same host:port combination.
  15. // In the production build, this file is replaced with an actual service worker
  16. // file that will precache your site's local assets.
  17. // See https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
  18. self.addEventListener('install', () => self.skipWaiting());
  19. self.addEventListener('activate', () => {
  20. self.clients.matchAll({ type: 'window' }).then(windowClients => {
  21. for (let windowClient of windowClients) {
  22. // Force open pages to refresh, so that they have a chance to load the
  23. // fresh navigation response from the local dev server.
  24. windowClient.navigate(windowClient.url);
  25. }
  26. });
  27. });
  28. `
  29. );
  30. } else {
  31. next();
  32. }
  33. };
  34. };