1

I have been using SquishIt to bundle and minify css and javascript. Now, I have to move to MVC bundles and replace SquishIt. SquishIt provides a way to to feed in dynamic content at runtime so that I can load things like LESS variables from a database.

Here's how I do in SquishIt when I need to feed in javascript string:

  .AddString("$(function() { alert('Need Support for dynamic content'); });")

Currently it looks like the only way I can bundle content in ASP.NET MVC bundles is if there is an actual file on the file system. Is there a way to read the content from database and feed to MVC bundle?

Pitamber Tiwari
  • 536
  • 1
  • 6
  • 19
  • Did you ever figure anything out on this? – AlexCuse Jan 27 '15 at 14:50
  • 1
    Yes, I did. Created a new bundle transform that takes in a string. Something like, `public class DynamicCSSContent : IBundleTransform { string content; public DynamicCSSContent(string content) { this.content = content; } public void Process(BundleContext context, BundleResponse response) { response.Content = content; response.ContentType = "text/css"; } }` However, had to create a separate method to merge two bundles to add the dynamic string to an existing bundle/css file – Pitamber Tiwari Jan 28 '15 at 20:36

0 Answers0