Search code examples
asp.net-mvc-5bundlecdn

Basic bundling of CDN in debug mode


Using the following:

bundles.Add(new ScriptBundle("~/bundles/myBundle", "//cdn.com/myscript.js").Include("~/Scripts/myscript.js"));

I can load from a CDN path in production, and fall back to a local copy of myscript.js in debug mode.

Great, but I don't want to do this - I want to load from the CDN path all the time, even in debug mode.

I tried supplying a CDN path in the Include method but I get an error since it needs to be a relative path (makes sense).

How can I load from the CDN permanently via bundling (regardless of 'mode')?


Solution

  • You can add this code in Application_Start()

    BundleTable.EnableOptimizations = true;