有没有办法从 SquishIt 中组合的 javascript 文件中删除哈希值?
我正在使用 SquishIt 在 MVC 3 项目中合并和缩小我的 javascript 文件。我正在尝试创建一个离线cache.manifest,而编辑之间的哈希代码变化简直要了我的命。有没有办法删除附加到捆绑包中的哈希值?
我签入了 BundleBase.cs 类并看到 HashKeyNamed
方法,但不知道在哪里使用它。
这是我现有的组合方法:
@Html.Raw(SquishIt.Framework.Bundle.JavaScript()
.Add("~/js/libs/persistence.js")
.Add("~/js/offline.common.js")
.Add("~/js/offline.syncmanager.js")
// snip...
.ForceRelease()
.WithMinifier(SquishIt.Framework.JavaScript.Minifiers.JavaScriptMinifiers.NullMinifier)
.Render("~/js/offline_script.js"))
I'm using SquishIt to combine and minify my javascript files in an MVC 3 project. I'm trying to create an offline cache.manifest and the hash codes changing between edits is killing me. Is there a way to remove the hash that is appended to the bundle?
I checked in the BundleBase.cs class and see a HashKeyNamed
method but can't figure out where I would use it.
Here is my existing method for combining:
@Html.Raw(SquishIt.Framework.Bundle.JavaScript()
.Add("~/js/libs/persistence.js")
.Add("~/js/offline.common.js")
.Add("~/js/offline.syncmanager.js")
// snip...
.ForceRelease()
.WithMinifier(SquishIt.Framework.JavaScript.Minifiers.JavaScriptMinifiers.NullMinifier)
.Render("~/js/offline_script.js"))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
抱歉我参加聚会迟到了。
在最新版本中,捆绑包上有一个名为 .WithoutRevisionHash() 的方法,可以满足您的需要。这种方法实际上是由于此处提到的 Jacob 的拉取请求而应运而生。
该方法本身只是先前存在的名为 .HashKeyNamed() 的方法的包装器,可以使用空字符串调用该方法,正如他指出的那样,以实现您所追求的结果。希望新方法更直观/更容易发现:)
Sorry I'm late to the party.
In the latest version, there is a method on bundles called .WithoutRevisionHash() that will do what you needed. This method actual came into being thanks to Jacob's pull request mentioned here.
The method itself is just a wrapper for a previously existing method called .HashKeyNamed() that could be called with an empty string as he pointed out to accomplish the result you're after. Hopefully the new method is a bit more intuitive/discoverable though :)
我不相信有办法。您可以在此处查看所有公共 API 选项: https:// /github.com/jetheredge/SquishIt/blob/master/SquishIt.Framework/Base/IBundle.cs
虽然它是 OSS,所以你可以随时分叉该项目并进行添加!
祝你好运。
I don't believe there is a way. You can see all the public API options here: https://github.com/jetheredge/SquishIt/blob/master/SquishIt.Framework/Base/IBundle.cs
It is OSS though, so you can always fork the project and make the addition!
Good luck.
我最近提交了一个pull,以便在SquishIt,但与此同时,我认为您可以通过创建自己的自定义
JavaScriptBundle
来实现这一点并使用HashKeyNamed()
方法。然后在您的
_Layout
中您可以执行以下操作:I've recently submitted a pull for some better support of this in SquishIt, but in the mean time, I think you can pull this off by creating your own custom
JavaScriptBundle
and using theHashKeyNamed()
method.Then in your
_Layout
you could do something like this: