diff --git a/index.js b/index.js index f39e331..bafd2f3 100644 --- a/index.js +++ b/index.js @@ -75,7 +75,8 @@ module.exports = { rootURL: this._getRootURL(), sourcemaps: this.app.options.sourcemaps, registrationDistPath: options.registrationDistPath, - serviceWorkerFilename: options.serviceWorkerFilename + serviceWorkerFilename: options.serviceWorkerFilename, + ignoreRegistration: options.ignoreRegistration }); let serviceWorkerTree = serviceWorkerBuilder.build('service-worker'); diff --git a/lib/service-worker-builder.js b/lib/service-worker-builder.js index ffd9aea..d230c09 100644 --- a/lib/service-worker-builder.js +++ b/lib/service-worker-builder.js @@ -89,7 +89,8 @@ module.exports = class ServiceWorkerBuilder { ], delimiters: ['{{', '}}'], ROOT_URL: this.options.rootURL, - SERVICE_WORKER_FILENAME: this.options.serviceWorkerFilename + SERVICE_WORKER_FILENAME: this.options.serviceWorkerFilename, + IGNORE_REGISTRATION: this.options.ignoreRegistration }; return new Rollup(tree, { diff --git a/service-worker-registration/index.js b/service-worker-registration/index.js index 6883159..8702cd9 100644 --- a/service-worker-registration/index.js +++ b/service-worker-registration/index.js @@ -4,7 +4,10 @@ let SUCCESS_HANDLERS = []; let ERROR_HANDLERS = []; if ('serviceWorker' in navigator) { - navigator.serviceWorker.register('{{ROOT_URL}}{{SERVICE_WORKER_FILENAME}}', { scope: '{{ROOT_URL}}' }) + if ('{{IGNORE_REGISTRATION}}' === 'true') { + console.log('registrationIgnored'); + } else { + navigator.serviceWorker.register('{{ROOT_URL}}{{SERVICE_WORKER_FILENAME}}', { scope: '{{ROOT_URL}}' }) .then(function(reg) { let current = Promise.resolve(); @@ -33,6 +36,7 @@ if ('serviceWorker' in navigator) { console.log('Service Worker registration failed with ' + error); }); }); + } }