goldhand / goldhand/sw-precache-webpack-plugin

Add sw-cache snippet to the bottom of the template with fingerprinted path

Open
#96 4 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
1.4k
Forks
101
PR merge metrics
No merged PRs in 30d

Description

## **BEFORE YOU SUBMIT** please read the following:

* [ ] **I'm submitting a bug report**
* [ ] **I'm submitting a feature request**
* [ x] **I'm submitting a support request**

**webpack version:**
2.5

**sw-precache-webpack-plugin version**:
0.9.2

**Please tell us about your environment:**
OSX 10.x

**Current behavior:**

I'm currently using [sw cache plugin to load the sw cache worker](https://github.com/goldhand/sw-precache-webpack-plugin). I'm following the instructions there (copy the snippet to the bottom of the page:

```html

if ('serviceWorker' in navigator) {
navigator.serviceWorker
.register("/sw-cache.js")
.then(function() {
console.log('Service worker registered!');
})
.catch(function(error) {
console.log('Error registering service worker: ', error);
});
}

```

**Expected/desired behavior:**

Current behaviour is fine, but doesn't take advantage of contenthash resource names from webpack. Now, creating the fingerprint sw cache is easy, injecting it in the template is not. Is there a way to use webpack to inject the snippet with the proper production `"sw-cache.js"` path?

My main issue with this is that, whenever I release a new version of a pwa app with new assets, loading the cached sw-cache is loading the invalidated set of assets.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.