Last active
June 1, 2016 16:08
-
-
Save blittle/c601c3a2c2d6800450aa7fe52416ce5a to your computer and use it in GitHub Desktop.
Sofe Plugin Middlware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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