title: Register a service-worker in index.html file that's located in SRC folder - ReactJS
body: <h2>Run service-worker from other folder</h2>
  
  <p>I'am trying to use service-worker to precache entire of PWA and i need to locate SW inside of SRC folder.</p>
  
  <p>How can I run my SW from <strong>public/index.html</strong>?</p>
  
  <p>I use create-react-app and i use google workbox to generate service-worker.</p>
  
  <p>I try to import SW into App.js file, but I catch an error:</p>
  
  <blockquote>
    <p>'importScripts' is not defined no-undef</p>
  </blockquote>
  
  <pre><code>importScripts(
    "https://storage.googleapis.com/workbox-cdn/releases/5.0.0/workbox-sw.js"
  );
  
  const precacheManifest = []; 
  
  workbox.routing.registerRoute(
    new RegExp("https://app.tessa.technology/api/"),
    new workbox.strategies.CacheFirst()
  );
  
  workbox.routing.registerRoute(
    new RegExp(
    "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
  ),
  new workbox.strategies.CacheFirst()
  );
  
  
   workbox.precaching.precacheAndRoute(self.__WB_MANIFEST);
  </code></pre>
  
  <ul>
  <li>public
  
  <ul>
  <li>manifest.js</li>
  <li>index.html</li>
  </ul></li>
  <li>SRC
  
  <ul>
  <li>JS</li>
  <li>CSS</li>
  <li>SW.js</li>
  </ul></li>
  </ul>