I recently ran into a problem on a website where the styling on the page was really messed up, but only in IE. My boss told me that most likely this is because the CSS package created contains CSS files from different directories, so I checked and did this. It was like the following:
bundles.Add(new StyleBundle("~/path/subpath/all").Include( "~/path/subpath/filename.css", "~/path/subpath/filename1.css", "~/path/subpath/filename2.css", "~/path/subpath/filename3.css", "~/path/subpath/anotherSubPath/filename.css", "~/path/subpath/anotherSubPath/filename1.css", "~/path/aDifferentSubPath/filename.css"));
He said that Bundling cannot work like this: you should only have files of the same directory in the Bundle, so I am breaking them up as shown below:
bundles.Add(new StyleBundle("~/path/subpath/all").Include( "~/path/subpath/filename.css", "~/path/subpath/filename1.css", "~/path/subpath/filename2.css", "~/path/subpath/filename3.css")); bundles.Add(new StyleBundle("~/path/subpath/anotherSubPath/all").Include( "~/path/subpath/anotherSubPath/filename.css", "~/path/subpath/anotherSubPath/filename1.css")); bundles.Add(new StyleBundle("~/path/aDifferentSubPath/all").Include( "~/path/aDifferentSubPath/filename.css"));
This worked and fixed our problem in IE. So now to my questions:
- Was my boss right? Can you not link files from different folders?
- If he was right, why would it just break in IE? And why should you only bundle files from the same directory?
- If he was not right, what could be the problem? And why was it necessary to split the knot, correcting it?
c # css asp.net-mvc bundle bundling-and-minification
Srb1313711
source share