Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
3 changes: 2 additions & 1 deletion lib/service-worker-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
6 changes: 5 additions & 1 deletion service-worker-registration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -33,6 +36,7 @@ if ('serviceWorker' in navigator) {
console.log('Service Worker registration failed with ' + error);
});
});
}
}


Expand Down