Link to other packages in BundleConfig.cs in an ASP.NET MVC4 application

I am working on an MVC4 application where I use WebOptimization to do all my resource handling (cat and min). I have several pages that are very similar, but you need some different styles per page after page.

So, I'm trying to reference one package (base styles) inside another package (page-specific styles), and I'm not very lucky. Here is what I have in my configuration:

bundles.Add(new StyleBundle("~/bundles/css/search").Include( "~/Content/css/partials/grid-controls.css", "~/Content/css/partials/grid.css", "~/Content/css/views/search.css")); bundles.Add(new StyleBundle("~/bundles/css/searchtrees").Include( "~/bundles/css/search", "~/Content/css/views/search/trees.css")); 

On the search trees page, I get tree.css, but nothing from the basic CSS search set.

How can I link to the first package in the second? I am sure there is a way just not too familiar with the set.

+7
source share
1 answer

You can reuse file links instead of links to another package. Something like that:

 var baseIncludes = new string [] { "~/Content/css/partials/grid-controls.css", "~/Content/css/partials/grid.css", "~/Content/css/views/search.css" }; // 'base' bundle references the base includes bundles.Add (new StyleBUndle ("~/bundles/css/search").Include (baseIncludes)); // other bundle references the base includes and some extras bundles.Add (new StyleBundle ("~/bundles/css/searchtrees").Include(baseIncludes).Include ("~/Content/css/views/search/trees.css")); 
+8
source

All Articles