Skip to content

Commit c7102fd

Browse files
committedAug 25, 2018
fix(workbox): infer default value of globDirectory from webpack config. fixes #83.
1 parent 3c99328 commit c7102fd

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed
 

Diff for: ‎packages/workbox/index.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,24 @@ module.exports = function nuxtWorkbox (moduleOptions) {
1717
return
1818
}
1919

20+
let options
21+
2022
const hook = builder => {
2123
debug('Adding workbox')
22-
const options = getOptions.call(this, moduleOptions)
24+
options = getOptions.call(this, moduleOptions)
2325
workboxInject.call(this, options)
2426
setHeaders.call(this, options)
2527
emitAssets.call(this, options)
2628
addTemplates.call(this, options)
2729
}
2830

31+
// Get client output path (#83)
32+
this.extendBuild((config, { isClient }) => {
33+
if (isClient && !options.globDirectory) {
34+
options.globDirectory = config.output.path
35+
}
36+
})
37+
2938
this.nuxt.hook ? this.nuxt.hook('build:before', hook) : this.nuxt.plugin('build', hook)
3039
}
3140

@@ -67,7 +76,7 @@ function getOptions (moduleOptions) {
6776
clientsClaim: true,
6877
skipWaiting: true,
6978
globPatterns: ['**/*.{js,css}'],
70-
globDirectory: path.resolve(this.options.buildDir, 'dist'),
79+
globDirectory: undefined,
7180
modifyUrlPrefix: {
7281
'': fixUrl(publicPath)
7382
},

0 commit comments

Comments
 (0)
Please sign in to comment.