如何使用System.js与CDN和本地回退? [英] How to use System.js with CDN and local fallback?

查看:227
本文介绍了如何使用System.js与CDN和本地回退?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行 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和本地回退?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆