Skip to content
Permalink
Browse files
feat: improve computed cacheId
  • Loading branch information
pooya parsa committed Mar 17, 2019
1 parent 23471c4 commit cd6c9cc6d7233145d212379aac514c3bc339a493
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
@@ -4,7 +4,7 @@ module.exports = {
workboxURL: undefined,
importScripts: [],
autoRegister: true,
dev: false,
dev: undefined,

// Config
config: {},
@@ -16,7 +16,7 @@ module.exports = {
// Precache
preCaching: [],
cacheOptions: {
cacheId: process.env.npm_package_name || 'nuxt',
cacheId: undefined,
directoryIndex: '/',
revision: undefined
},
@@ -70,6 +70,11 @@ function getOptions (moduleOptions) {
options.preCaching.unshift(options.offlinePage)
}

// Default cacheId
if (options.cacheOptions.cacheId === undefined) {
options.cacheOptions.cacheId = (process.env.npm_package_name || 'nuxt') + (this.options.dev ? '-dev' : '-prod')
}

// Normalize runtimeCaching
options.runtimeCaching = options.runtimeCaching.map(entry => ({
...entry,
@@ -83,7 +88,7 @@ function getOptions (moduleOptions) {
}

// Workbox Config
if (!options.config.debug) {
if (options.config.debug === undefined) {
// Debug field is by default set to true for localhost domain which is not always ideal
options.config.debug = options.dev || this.options.dev
}
@@ -96,7 +96,7 @@ workbox.precaching.precacheAndRoute([
\\"/offline.png\\",
\\"precache.js\\"
], {
\\"cacheId\\": \\"nuxt\\",
\\"cacheId\\": \\"nuxt-prod\\",
\\"directoryIndex\\": \\"/\\"
})

0 comments on commit cd6c9cc

Please sign in to comment.