用于生产和缓存管理的SystemJS版本控制(requirejs urlArgs替代) [英] SystemJS versioning for production and cache management (requirejs urlArgs alternative)
问题描述
我想从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?
推荐答案
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屋!