Skip to content

Instantly share code, notes, and snippets.

@edoardocavazza
Last active December 20, 2017 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edoardocavazza/77048c0d3a7ef78296157ddbe7ad4c4a to your computer and use it in GitHub Desktop.
Save edoardocavazza/77048c0d3a7ef78296157ddbe7ad4c4a to your computer and use it in GitHub Desktop.
// import Unchained core and plugins.
importScripts(
'node_modules/unchained-js/lib/core.js',
'node_modules/unchained-js/lib/plugins/babel.js',
'node_modules/unchained-js/lib/plugins/resolve.js'
);
// intercept fetch events.
this.addEventListener('fetch', (event) => {
// verify if requested resource is an import.
if (Unchained.check(event)) {
event.respondWith(
// resolve the resource response.
Unchained.resolve(event)
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment