javascriptasp.net-mvc-3squishit

Is there a way to remove the hash from combined javascript files in SquishIt?


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"))

Solution

  • 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 :)