I am trying to bundle assets. I read Is there something in Sitecore 8.2 that breaks bundling? which was the simplest example I could find. My RegisterBundles.Void() method is not being hit and minified bundles are not being created. We are running Sitecore 9.0.2

In my config:

    <processor type="MySite.Project.MySite.Pipelines.RegisterBundles, MySite.Project.MySite" />

In My Register Class I tested both single file and wildcard:

public class RegisterBundles : Sitecore.Mvc.Pipelines.Loader.InitializeRoutes
    public override void Process(PipelineArgs args)

    private void Register(BundleCollection bundles)
        bundles.Add(new ScriptBundle("~/Assets/min/js").Include("~/Assets/js/*.js"));
        bundles.Add(new ScriptBundle("~/Assets/min/test").Include("~/Assets/js/mysite.global.js"));

In My Layout/View:


When I do a show config my element is the last one added to the initialize element.

When I do a view source the script tag is rendering correctly but my process method is never hit so the assets are never registered. Do I need to patch instead or patch after or something in my config?

1 Answer 1


Your guess was correct.

You were missing patch:before statement.

Your config should look like this:

          type="MySite.Project.MySite.Pipelines.RegisterBundles, MySite.Project.MySite" 
          patch:before="processor[@type='Sitecore.Pipelines.Loader.ShowVersion, Sitecore.Kernel']" />
  • Thanks Peter I added some logging and can see the process method is now hit. However the js is not being bundled into the min folder. I tried adding BundleTable.EnableOptimizations = true to the Register method but didn't seem to make a difference. any ideas
    – JKerny
    Oct 17, 2018 at 23:21
  • Minification is another topic. You should have another processor but this time in <preprocessRequest> to enable optimizations. Take a look in this answer sitecore.stackexchange.com/q/14102/2056 for further details Oct 18, 2018 at 4:45
  • 1
    Cheers. I've been thrown into a project as a full stack dev when I have minimal knowledge of frontend. I'll post another question if I can't work out the preprocessor.
    – JKerny
    Oct 18, 2018 at 22:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.