I have defined the following bundle, inside my asp.net mvc-5 web application:-
var bundle5 = new StyleBundle("~/Content/css")
.Include("~/Content/bootstrap.css")
.Include("~/Content/style.css")
.Include("~/fonts/font-awesome.css")
.Include("~/Content/touchTouch.css")
;
bundle5.Orderer = new NonOrderingBundleOrderer();
bundles.Add(bundle5);
class NonOrderingBundleOrderer : IBundleOrderer
{
public IEnumerable<BundleFile> OrderFiles(BundleContext context, IEnumerable<BundleFile> files)
{
return files;
}
}
and i am referencing this bundle inside the _layout view as follow:-
@Styles.Render("~/Content/css")
now this will render the below fonts, which is not what i am looking for:-
but if i render the same css files defined inside the bundle file individually as follow:-
i will get the effect i want as follow:-
now i checked the browser using F12 as seems using the two approaches i can see exactly the same css rules applies to the page.. but not sure why the final result is not the same ?
also if i split the css into two bundles as follow:-
var bundle5 = new StyleBundle("~/Content/css")
.Include("~/Content/bootstrap.css")
// .Include("~/Content/style.css")
.Include("~/fonts/font-awesome.css")
.Include("~/Content/touchTouch.css")
;
bundle5.Orderer = new NonOrderingBundleOrderer();
bundles.Add(bundle5);
var bundle6 = new StyleBundle("~/Content/Customcss")
.Include("~/Content/style.css")
;
bundle6.Orderer = new NonOrderingBundleOrderer();
bundles.Add(bundle6);
and render them inside the view as follow:-
@Styles.Render("~/Content/css")
@Styles.Render("~/Content/Customcss")
the result will be correct,, so i am really confused on what is going on ? i doubt the order of the css matters in my case, because when i define the css individually it work well. so it is not related to having the style.css render after the other scripts,, because when they are render individually the style.css is second in the order and the result was correct..
EDIT
now i define the following bundle to include all the css :-
var bundle5 = new StyleBundle("~/Content/css")
.Include("~/Content/bootstrap.css")
.Include("~/fonts/font-awesome.css")
.Include("~/Content/touchTouch.css")
.Include("~/Content/style.css")
;
bundle5.Orderer = new NonOrderingBundleOrderer();
bundles.Add(bundle5);
and i reference it inside my _layout view as follow:-
@Styles.Render("~/Content/css");
here is the generated code for the bundle :-
<link href="/Content/css?v=uEwsjHXMY4OZeiDkOmQdOIlIjQMZpRc0advYoZe5jPg1" rel="stylesheet"/>
if i click on the bundle i can see that there are some errors at the beginning of the file:-
/* Minification failed. Returning unminified contents.
(7384,1): run-time error CSS1019: Unexpected token, found '@import'
(7384,9): run-time error CSS1019: Unexpected token, found 'url(//fonts.googleapis.com/css?family=Ubuntu:400,700)'
(7385,2): run-time error CSS1019: Unexpected token, found '@import'
(7385,10): run-time error CSS1019: Unexpected token, found 'url(//fonts.googleapis.com/css?family=Oswald)'
*/
/*!
so could this be causing the problem ? now i have these lines inside my style.css:-
@import url(//fonts.googleapis.com/css?family=Ubuntu:400,700);
@import url(//fonts.googleapis.com/css?family=Oswald);
so could those @import
causing the problem inside the bundle ? again if i include the style.css on a separate bundle i will not get any error , seems the problem will happen if i include the style.css
inside a shared bundle (i mean by shared bundle as bundle that contain other css files),, so can any one adivce how i can fix this ?