Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何使用第三方的CDN #59

Open
kanbekotori opened this issue Nov 8, 2016 · 1 comment
Open

如何使用第三方的CDN #59

kanbekotori opened this issue Nov 8, 2016 · 1 comment

Comments

@kanbekotori
Copy link

domain属性可以配置CDN的前缀地址,但是我希望配置一个第三方的完整URL地址,比如http://cdn.bootcss.com/jquery/2.2.2/jquery.js

@oxUnd
Copy link
Contributor

oxUnd commented Nov 13, 2016

这个有个误区,你又想用 FIS 来管理你的源码,又想使用外部依赖文件。

但这中间有个事情,你依赖的第三方版本可能升级得没有那么频繁,甚至一般年来不了一次。

那么此类文件你直接写 link url 不就可以了?

如果你还是想着在某个地方配置比较好,你可以在想要第三方依赖的时候。设定一个全局变量,比如;

  [!--THIRD_PARTY_SCRIP--]
</body>

然后在配置文件中实现一个函数;

function thirdPartyScript()
{
  return '<link url=""> ....';
}
fis.match('*.html', {
    deploy: [fis.plugin('replace', {
      from: '[!--THIRD_PARTY_SCRIP--]',
      to: thirdPartyScript()
    }), fis.plugin('deliver')]
});

来看上去配置的方式实现第三方 cdn 依赖。

当然还是参考上面说的,你得给你的资源分个类。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants