用于生产和缓存管理的SystemJS版本控制(requirejs urlArgs替代) [英] SystemJS versioning for production and cache management (requirejs urlArgs alternative)

查看:134
本文介绍了用于生产和缓存管理的SystemJS版本控制(requirejs urlArgs替代)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从requirejs迁移到SystemJS,但是我找不到像requirejs那样用于模块版本控制的解决方案. 例如在生产中(ASP.Net网站),我将RequireJS设置如下:

I would like to migrate to SystemJS from requirejs however I am failing to find a solution as requirejs have for module versioning. For example in production (ASP.Net website) I have set RequireJS like this:

require.config({
            baseUrl: "@Url.Content("~/Scripts/")",
            urlArgs: "buildNumber=@(File.GetLastWriteTime(ViewContext.Controller.GetType().Assembly.Location).ToBinary().ToString() + typeof(Foundation.MvcApplication).Assembly.GetName().Version)",
            ...
});

它保证一旦在生产环境中重新发布项目,文件将被重新加载,并一直保持这种状态直到重新加载.

It guarantees that the file will be reloaded once the project is republished in the production environment, and kept that way until it is reloaded.

但是,我没有找到针对SystemJS的任何解决方案(由于SystemJS管理更多类型的模块,因此我想迁移到它).

However, I did not find any solution for this for SystemJS (As SystemJS manage more types of modules, I would like to migrate to it).

有人在生产中使用SystemJS并遇到相同的问题,您知道SystemJS中的"urlArgs"参数(或插件)吗?

Has anyone used SystemJS in production and had the same issue, do you know an "urlArgs" parameter (or plugin) in SystemJS?

推荐答案

长话短说:SystemJS的github上有关于

Long story short: there were issues on github of SystemJS about cache bust. But thing are not offically implemeted yet. At the moment there is a custom hook, which can be easily added

var buildNumber = 1234, // made your own build number
    systemLocate = System.locate;
System.locate = function(load) {
  return Promise.resolve(systemLocate.call(this, load)).then(function(address) {
    return address + '?build='+buildNumber;
  });
}

编辑修正拼写错误

这篇关于用于生产和缓存管理的SystemJS版本控制(requirejs urlArgs替代)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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