Skip to content

Instantly share code, notes, and snippets.

@blittle
Last active June 1, 2016 16:08
Show Gist options
  • Save blittle/c601c3a2c2d6800450aa7fe52416ce5a to your computer and use it in GitHub Desktop.
Save blittle/c601c3a2c2d6800450aa7fe52416ce5a to your computer and use it in GitHub Desktop.
Sofe Plugin Middlware
System.config({
sofe: {
manifest: {
"someInternalService": "http://somelocation.com/service-1.0.0.js"
},
manifestUrl: 'https://somelocation.com/available-services.json',
middleware: {
preLocate: (load, locate) => {
},
postLocate: [(url, resolve) => {}, (url, resolve) => {}],
fetch: [
function (load, fetch) {
console.log('Sofe Pre-fetch', load.name);
systemFetch.apply(null, arguments);
},
function (load, fetch) {
if (load.name.indexOf('css') > -1) {
if (!hasWindow) {
return Promise.resolve('');
}
return new Promise((resolve) => {
System.import('sofe-cssmodules/lib/browserLoader.js')
.then((Loader) => {
const loader = new Loader.default();
return resolve(loader.fetch.call(this, load, systemFetch));
});
});
} else {
return systemFetch.apply(this, arguments);
}
}
]
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment