Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use System.js with CDN and local fallback?

I ran jspm install angular and it installed it locally to my jspm_packages folder.

From code, I use regular ES6 imports like import angular from 'angular'.

What do I need to do in order to load angular from a CDN and fallback to a local version if the CDN is unavailable?

like image 371
Natan Avatar asked Feb 09 '23 12:02

Natan


1 Answers

You can have different config.js files for development and production, where the production one gets angular from a CDN while development gets it locally. However, there is not (as far as I know) currently a way to have SystemJS try one source, then if that fails fallback to another source.

System.config({
    "map": {
        "jquery": "https://code.jquery.com/jquery-2.1.4.js"
    }
});
like image 137
Micah Zoltu Avatar answered Mar 06 '23 17:03

Micah Zoltu