atashbahar.com

thoughts, ideas and ...

ASP.NET MVC CSS Bundling Pitfalls

This might seem obvious to some but I think it is still worth mentioning.

You should always bundle CSS files that are in the same folder and the Virtual Path of that bundle must match that folder's path. For example if you are bundling multiple CSS files in "~/Content/CSS/" folder, your bundle's Virtual path should be something like "~/Content/CSS/All".

The reason being images inside CSS files are relative to the location of the CSS file. So if the virtual path doesn't match the CSS file location images won't load.