Skip to content

Commit

Permalink
feat(workbox): add options.autoRegister
Browse files Browse the repository at this point in the history
  • Loading branch information
Pooya Parsa committed Nov 17, 2017
1 parent a0fb908 commit f1e1fe1
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions packages/workbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function getOptions (moduleOptions) {
}

const options = Object.assign({
autoRegister: true,
routerBase,
publicPath,
swSrc: path.resolve(this.options.buildDir, 'sw.template.js'),
Expand Down Expand Up @@ -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}/`)
}
})
}
}

// =============================================
Expand Down

0 comments on commit f1e1fe1

Please sign in to comment.