Currently it is impossible for devs to easily work together. While debugging our code minification and bundling are turned off and so is the cache buster. This leads to every dev that touches javascript having to open every javascript file and force-refresh to make sure they aren't missing changes.
I found a couple references that I thought might work but none of the implementations have worked out yet.
The first is to apply a transform to the individual Bundles via an IBundleTransform
.
Public Class DebugCacheBuster
Implements IBundleTransform
Public Sub Process(context As BundleContext, response As BundleResponse) Implements IBundleTransform.Process
If BundleTable.EnableOptimizations Then
Exit Sub
End If
For Each file As BundleFile In response.Files
file.IncludedVirtualPath &= GetPathHash(HostingEnvironment.MapPath(file.IncludedVirtualPath))
Next
End Sub
End Class
This looked promising but I have not been able to get it to work. I tried adding a new instance of this class to the constructor of each bundle and I also tried looping over all of the bundles after they were created. My break-points are hit and IncludedVirtualPath
appears to have been updated. After continuing on with rendering the paths are not updated.
I also tried to create a custom VirtualPathProvider
and a custom VirtualFile
and overrode VirtualPath to return the correct value but again, when it rendered, the path was bare.
Did I do something wrong with the transform? Is there some other way to implement this?
Apparently this code will not work with version 1.1.0 of System.Web.Optimizations. After upgrading to version 1.1.3 (and adding an assembly binding redirect to solve a compatibility issue with Web Grease) the snippet in the question works flawlessly.