title: Service-worker: Cache data from asset-manifest.json created by webpack
body: <p>I was trying to cache and serve all my static assets using service-worker.
  So for that, I wrote service-worker code as below: </p>
  
  <pre><code>var filesToCache = [
    '/src/assets/images/a.png',
    '/src/assets/images/b.png',
    '/src/assets/images/c.svg',
    '/src/assets/images/d.svg',
  ];
  </code></pre>
  
  <p>and the caching part would be like </p>
  
  <pre><code>self.addEventListener('install', function(event) {
    console.log('cache static assets');
    event.waitUntil(
     caches.open(dataCacheName)
     .then(function(cache) {
       return cache.addAll(filesToCache);
     })
    );
  });
  </code></pre>
  
  <p>This works perfectly <strong>until I add revisioning to all my assets</strong> using <code>webpack</code>. I use <code>webpack-assets-manifest</code> to create a manifest file of the revisioned assets. That will look like:</p>
  
  <pre><code>{
    "src/assets/images/a.png": "/caa80bc36fced529800b0fc6e1d10bbc.png",
    "src/assets/images/b.png": "/973d60bc669967dd3a29d09f45fbd7bd.png",
    "src/assets/images/c.svg": "/727f31a23fe57eaf9ac47c6f23fc2af8.svg",
    "src/assets/images/d.svg": "/b95ecc4ec50d56eca49231508d57223f.svg"
  }
  </code></pre>
  
  <p>After doing this, my <code>html</code> files are looking for a revisioned image/asset URL instead of <code>a.png</code>. There fails my <code>service-worker</code> caching and serving.</p>
  
  <p>Question: <strong>How can I use service-worker to cache my assets from a <code>json</code> file instead of manually created <code>filesToCache</code> array?</strong> Or how can I cache the files to service worker while revisioning using <code>webpack</code> plugins</p>
  
  <p>I have tried to use <code>sw-precache</code>, but couldn't figure out much about how to use in webpack config file.</p>