BundleConfig routing not rendering all files after publishing live
I have a routeconfig set up for a microsite within umbraco and am using BundleConfig to get my styles and scripts.
I made everything working on my local site however when I published everything live the bootstrap.css does not render in html head while the other custom css file renders.
public class BundleConfig
{
// For more information on bundling, visit https://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles)
{
//bundles.IgnoreList.Clear();
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate*"));
// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at https://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js"
//,"~/Scripts/respond.js"
));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/css/style.supplier.css",
"~/Content/css/bootstrap.css"));
}
}
This will create one combined, minified CSS file. So all three CSS files will be combined into one file and minified. So in live you would only ever expect to have one CSS file, but it should contain all three files combined. Have you checked the source of the combined file to definitely ascertain the first file hasn't been added?
However the problem is not that the path is not rendered in the source - I believe it's only a symptom.
The problem is that the classes from this file are not available on the live site - I can only assume that they are not thus included in the minified file.
Since it doesn't happen on my local (styles are correct) only on live (styles are missing) I can also assume that the minified file should exist on my local - I can't see anything new under Content/css though and the style paths are rendered in the page source.
If you change the site to run in Debug mode, bundling will not combine the files, but instead render the paths, I would do that, and use a tool like fiddler to see if you have any 404 errors.
BundleConfig routing not rendering all files after publishing live
I have a routeconfig set up for a microsite within umbraco and am using BundleConfig to get my styles and scripts.
I made everything working on my local site however when I published everything live the bootstrap.css does not render in html head while the other custom css file renders.
cshtml declaration:
BundleConfig content:
Localhost head:
Live head:
As you can see only
declaration is missing in live source.
I checked and the file exists in the correct location on live. I also checked in other browsers.
Any ideas while the link may not be rendering?
I believe you need to make this changes to your web.config
Inside the appSettings section, add "~/bundles"
No, it's always cutting first bundle file, eg. if I do this:
blank.css will not render in the source while the two other files will render.
In my experience missing files always means you have the path wrong. It will silently disclude files it cannot find on disk.
I thought so too but when
"~/Content/css/bootstrap.css"
goes as first item ofInclude
then it does not render in the page source.If it comes as any of the following items - it does render on the page and render correct link.
So - in essence the position matters - and not the path is wrong.
Same with any other path - if I put any other path as first item then it does not render while the following items always render.
Just to be clear about your expectations for this:
This will create one combined, minified CSS file. So all three CSS files will be combined into one file and minified. So in live you would only ever expect to have one CSS file, but it should contain all three files combined. Have you checked the source of the combined file to definitely ascertain the first file hasn't been added?
And what is supposed to be the path/ filename of the combined file?
In the above cass it would be
~/Content/css
I believe. The path is the first parameter.But by convention I would change it to
~/bundles/Content/css
I would then do as John suggests and add
~/bundles
to theumbracoReservedPaths
section inweb.config
to ensure Umbraco doesn't intercept these paths.What would be the minified filename then?
However the problem is not that the path is not rendered in the source - I believe it's only a symptom.
The problem is that the classes from this file are not available on the live site - I can only assume that they are not thus included in the minified file.
Since it doesn't happen on my local (styles are correct) only on live (styles are missing) I can also assume that the minified file should exist on my local - I can't see anything new under Content/css though and the style paths are rendered in the page source.
I'm not sure why it's not there, but the generated files are not physical files - they only exist in memory.
I'd read: https://docs.microsoft.com/en-us/aspnet/mvc/overview/performance/bundling-and-minification
If you change the site to run in Debug mode, bundling will not combine the files, but instead render the paths, I would do that, and use a tool like fiddler to see if you have any 404 errors.
is working on a reply...