Permalink
Browse files

feat(workbox): add options.autoRegister

  • Loading branch information...
pi0 committed Nov 17, 2017
1 parent a0fb908 commit f1e1fe127c7a9e15e74dbed243194c68a6422ed2
Showing with 13 additions and 10 deletions.
  1. +13 −10 packages/workbox/index.js
@@ -44,6 +44,7 @@ function getOptions (moduleOptions) {
}
const options = Object.assign({
autoRegister: true,
routerBase,
publicPath,
swSrc: path.resolve(this.options.buildDir, 'sw.template.js'),
@@ -99,16 +100,18 @@ function addTemplates (options) {
})
// Add sw.plugin.js
const swURL = `${options.routerBase}/${options.swURL || 'sw.js'}`
this.addPlugin({
src: path.resolve(__dirname, 'templates/sw.plugin.js'),
ssr: false,
fileName: 'sw.plugin.js',
options: {
swURL: fixUrl(swURL),
swScope: fixUrl(`${options.routerBase}/`)
}
})
if (options.autoRegister) {
const swURL = `${options.routerBase}/${options.swURL || 'sw.js'}`
this.addPlugin({
src: path.resolve(__dirname, 'templates/sw.plugin.js'),
ssr: false,
fileName: 'sw.plugin.js',
options: {
swURL: fixUrl(swURL),
swScope: fixUrl(`${options.routerBase}/`)
}
})
}
}
// =============================================

0 comments on commit f1e1fe1

Please sign in to comment.