Skip to content
Permalink
Browse files
feat(workbox): allow cache names to be configured (#154)
  • Loading branch information
jezhodges authored and pi0 committed Mar 2, 2019
1 parent 45ac27d commit 2d7ed53a3e66fa8d9607591ddfc9225ecbc7744a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
@@ -48,6 +48,10 @@ It is recommanded to test workbox using `nuxt build`/`nuxt start`. You can enabl

<!-- Config -->

### `cacheNames`

(Object) Configure the workbox cache names. See [workbox docs](https://developers.google.com/web/tools/workbox/guides/configure-workbox#configure_cache_names) for more information on this.

### `config`

(Object) Options to be passed to workbox before using it's modules. By default `debug` field will be set to `false` for production builds.
@@ -9,6 +9,11 @@ importScripts(<%= [options.workboxURL, ...options.importScripts].map((i) => `'${
workbox.setConfig(<%= JSON.stringify(options.config, null, 2) %>)
<% } %>

<% if (options.cacheNames) {%>
// Set workbox cache names
workbox.core.setCacheNameDetails(<%= JSON.stringify(options.cacheNames, null, 2) %>)
<% } %>

<% if (options.clientsClaim) { %>
// Start controlling any existing clients as soon as it activates
workbox.core.clientsClaim()
@@ -64,6 +64,12 @@ workbox.setConfig({
\\"debug\\": true
})
// Set workbox cache names
workbox.core.setCacheNameDetails({
\\"prefix\\": \\"test\\",
\\"googleAnalytics\\": \\"test-ga\\"
})
// Start controlling any existing clients as soon as it activates
workbox.core.clientsClaim()
@@ -30,6 +30,10 @@ module.exports = {
config: {
debug: true
},
cacheNames: {
prefix: 'test',
googleAnalytics: 'test-ga'
},
importScripts: [
'custom-sw.js'
],

0 comments on commit 2d7ed53

Please sign in to comment.