I have two VS projects, one for the main site and one for the “static content” website, where all css, js, images and other static content will be saved and accessible via a cookieless.
So, I have BundleConfig.cs on a static site that creates all the packages:
public class BundleConfig { public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new StyleBundle("~/bundles/styles").IncludeDirectory("~/app/styles", "*.css", true)); bundles.Add(new ScriptBundle("~/bundles/scripts").IncludeDirectory("~/app/src", "*.js", true)); } }
And on the main site, I have another BundleConfig.cs, where I point the main site to the static content site as follows:
public class BundleConfig { public static void RegisterBundles(BundleCollection bundles) { var staticWebsite = ConfigurationManager.AppSettings["StaticWebsite"]; var versionNumber = ConfigurationManager.AppSettings["VersionNumber"]; Styles.DefaultTagFormat = string.Format("<link href='{0}{{0}}?v={1}' rel='stylesheet'/>", staticWebsite, versionNumber); Scripts.DefaultTagFormat = string.Format("<script src='{0}{{0}}?v={1}'></script>", staticWebsite, versionNumber); } }
Now I can use @Styles.Render("~/bundles/styles") and @Scripts.Render("~/bundles/scripts") , which render as I want, and it works fine:
<link href='http://mycookielessdomain.com/bundles/styles?v=1.0.0.0' rel='stylesheet'/> <script src='http://mycookielessdomain.com/bundles/scripts?v=1.0.0.0'></script>
The problem is that the content is always minimized and linked regardless of whether debug=true exists or not. Even if I use BundleTable.EnableOptimization = false in both files, BundleConfig.cs, @Styles.Render() and @Scripts.Render() still display only one tag and link to content that has been reduced.
I understand that the main site will not know the individual files that were included in the static content site, but I hope there is some way to manually specify these paths on the BundleConfig main site so that the Render () methods can list them individually. when optimization is turned off ... if I can make them turn off, that is.