title: MVC bundles for remote CDN and local files
body: <p>I am currently using MVC 4 and I have ran into a limitation of the bundling I was hoping someone could help me with. I want to include both CDN delivered assets as well as local scripts in bundles. The problem is, that <code>RegisterBundles(BundleCollection bundles)</code> is a static method that accepts a static object as a parameter. Once I set <code>useCDN</code> and <code>enableOptimizations</code> to true, I can't debug and step through my local javascript anymore because it gets minified. Here is what I have so far:</p>
  
  <pre><code>public class BundleConfig
  {
  
      public static void RegisterBundles(BundleCollection bundles)
      {
          // allow URLs in bundle declaration
          BundleTable.EnableOptimizations = true;
          bundles.UseCdn = true;
  
          string asset1= "/assets/javascript/framework/asset1/asset1.min.js";
          bundles.Add(new ScriptBundle("~/asset1", assembleBundleURL(asset1)));
  
          string asset2= "/assets/javascript/framework/asset2/asset2.mobile-1.3.1.min.js";
          bundles.Add(new ScriptBundle("~/asset2", assembleBundleURL(asset2)));
  
          bundles.Add(new ScriptBundle("~/bundles/myApp").Include(
              "~/Scripts/myApp/myApp1.js",
              "~/Scripts/myApp/myApp2.js",
              "~/Scripts/myApp/myApp3.js",
              "~/Scripts/myApp/myApp4.js"));
      }
  
      internal static string assembleBundleURL(string asset)
      {
          if (ConfigurationManager.AppSettings["externalWebAssetsHost"] == null)
              throw new Exception("externalWebAssetsHost url is required in web.config");
  
          string host = ConfigurationManager.AppSettings["externalWebAssetsHost"].ToString();
          string protocol = "https://";
          return protocol + host + asset;
      }
  
  }
  </code></pre>
  
  <p>I want to include the CDN urls here through the bundling because it allows me to use web.config transforms to specify different URLs for my different environments. Otherwise I would just specifically include the CDN urls in the HTML and be done with it. The CDN assets I want to include are other in-house javascript libraries for common functionality and I don't want to include these in-house assets locally because it could become a versioning issue. </p>
  
  <p>Is there a way to have two <code>RegisterBundles</code> methods that write to two separate <code>BundleTables</code>?
  Or is there a way to have the bundling be instance driven instead of static so that for every differently sourced bundle (cdn or local) you can have different properties on the <code>BundleTable</code> class? In the end I want to be able to run my app locally in debug mode and be able to step through the javascript of my local files, but still pull in minified references from CDNs.</p>
  
  <p>EDIT</p>
  
  <p>If I set <code>EnableOptimizations</code> to false and remove the "min" from the asset filename, the bundles are still not rendered to the HTML in DEBUG mode. It seems like <code>EnableOptimizations</code> must be true if <code>UseCdn</code> is true.</p>
  
  <p>UPDATE</p>
  
  <p>I understand why the above code doesn't allow me to step into my javascript in debug mode. My question is: Is there a way to have more than one <code>BundleTable</code> class? Can the framework be extended to allow this instead of the static methods?</p>