I'm trying to implement bundling in Sitecore 8.2 and followed all the steps in this document.
The breakpoint is hit for the RegisterBundles
method, but the assets are not rendered on page.
In the layout, it only renders this:
<link href="/bundles/css?v=" rel="stylesheet"/>
The processor specified in the document did not work for me. The breakpoint wasn't being hit. I changed it to this:
patch.config
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<initialize>
<processor patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.ShowVersion, Sitecore.Kernel']"
type="MyProject.Web.Pipelines.RegisterPlatformBundles, MyProject" />
</initialize>
</pipelines>
</sitecore>
</configuration>
RegisterPlatformBundles.cs
private void RegisterBundles(BundleCollection bundles)
{
/// Bundled CSS
bundles.Add(new StyleBundle("~/bundles/css").Include(
"~/Assets/css/main.css?v=202001236",
"~/Assets/css/dev.css?v=202001231"
));
}
Layout.cshtml
<head>
@Styles.Render("~/bundles/css")
</head>
UPDATE:
@Mahendra's suggestion worked for me.
I removed the versions from the css references.
Also, to fix the incorrect image/font paths, I changed the RegisterBundles
method to this:
private void RegisterBundles(BundleCollection bundles)
{
/// Bundled CSS
bundles.Add(new StyleBundle("~/bundles/css")
.Include("~/Assets/css/main.css", new CssRewriteUrlTransform())
.Include("~/Assets/css/dev.css", new CssRewriteUrlTransform()));
}
<link href="/bundles/css?v=blNztwxsF5QM3OLfN6fFdLya8YpG5qMfrbHhfcIUFP81" rel="stylesheet"/>
. But how do I add the versions for a particular file here. – Qwerty Jan 28 '20 at 15:04StyleBundle
class required a physical file and do not accept any query string. updated the same in the answer. – Mahendra Shekhawat Jan 28 '20 at 16:42