Skip to content

Commit

Permalink
fix(workbox): infer default value of globDirectory from webpack confi…
Browse files Browse the repository at this point in the history
…g. fixes #83.
  • Loading branch information
pi0 committed Aug 25, 2018
1 parent 3c99328 commit c7102fd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/workbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,24 @@ module.exports = function nuxtWorkbox (moduleOptions) {
return
}

let options

const hook = builder => {
debug('Adding workbox')
const options = getOptions.call(this, moduleOptions)
options = getOptions.call(this, moduleOptions)
workboxInject.call(this, options)
setHeaders.call(this, options)
emitAssets.call(this, options)
addTemplates.call(this, options)
}

// Get client output path (#83)
this.extendBuild((config, { isClient }) => {
if (isClient && !options.globDirectory) {
options.globDirectory = config.output.path
}
})

this.nuxt.hook ? this.nuxt.hook('build:before', hook) : this.nuxt.plugin('build', hook)
}

Expand Down Expand Up @@ -67,7 +76,7 @@ function getOptions (moduleOptions) {
clientsClaim: true,
skipWaiting: true,
globPatterns: ['**/*.{js,css}'],
globDirectory: path.resolve(this.options.buildDir, 'dist'),
globDirectory: undefined,
modifyUrlPrefix: {
'': fixUrl(publicPath)
},
Expand Down

0 comments on commit c7102fd

Please sign in to comment.