问题描述
我运行 jspm install angular
,并将其本地安装到我的jspm_packages文件夹。
I ran jspm install angular
and it installed it locally to my jspm_packages folder.
从代码,我使用常规的ES6导入,如导入角度从'angular'
。
From code, I use regular ES6 imports like import angular from 'angular'
.
我需要做什么才能加载如果CDN不可用,则从CDN角度回退到本地版本。
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?
推荐答案
您可以有不同的 config.js
用于开发和生产的文件,其中生产一个从CDN角度开发,而开发在本地。然而,目前还没有(据我所知),让SystemJS尝试一个来源的方法,那么如果这个来源不能回落到另一个源头。
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"
}
});
这篇关于如何使用System.js与CDN和本地回退?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!