将CDN与ember-cli一起使用 [英] Using CDN with ember-cli

查看:59
本文介绍了将CDN与ember-cli一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的使用ember-cli开发的应用程序中,我还需要一些外部资源,例如引导程序;
现在我正在通过Brocfile导入它:

In my app, developed using ember-cli, I need also some external resources like bootstrap; now I'm importing it through the Brocfile:

app.import('bower_components/bootstrap/dist/css/bootstrap.css');
app.import('bower_components/bootstrap/dist/js/bootstrap.js');

是否可以使用CDN代替本地文件,还可以定义对本地文件的回调CDN离线吗?

Is it possible to use a CDN instead of local file, defining also a callback to local file in case the CDN is offline?

推荐答案

Ember-cli-cdn 听起来像是我的部分解决方案。这是自述文件的引文:

Ember-cli-cdn sounds like a partial solution to the problem to me. Here is a quote from the Readme:


此插件允许在开发过程中使用库的本地副本,然后自动切换到CDN

This addon allows to work with local copies of libraries during development, and then automate switching to your CDN version when you deploy your application.

但这不能解决如果CDN脱机则回退到本地文件的问题。我知道的唯一模式(也用在ember中)是将脚本加载放在html的末尾,即使CDN没有响应也允许页面呈现。

But it doesn't solve the "fallback to local file if CDN is offline" problem. The only pattern I am aware of (also used in ember) is to put the script loading at the end of the html allowing page rendering even if the CDN isn't responding.

这篇关于将CDN与ember-cli一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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