0

I have the following configuration:

   public static void RegisterBundles(BundleCollection bundles)
        {
    var picbundle = new ScriptBundle("~/bundles/pic.components")
                        .IncludeDirectory("~/TypeScript/Components","*.js",true)
                               .IncludeDirectory("~/TypeScript/Services", "*.js", true);
bundles.Add(picbundle);
}

Inside the components folder there is files needed to be loaded before others.I am using wild card to load all javascript files because my boss thought it's cleaner and easier than writing each file name.

I found this solution over stack overflow , which implement your own custom bundle to load files in the right order.

I tried to do it this way,but I'm not sure I'm using it right because it's not working

public IEnumerable<BundleFile> OrderFiles(BundleContext context, IEnumerable<BundleFile> files)
        {
            return files;
        }   

    }


     public class BundleConfig
        {
            public static void RegisterBundles(BundleCollection bundles)
            {
    var picbundle = new ScriptBundle("~/bundles/pic.components")
.Include("~/TypeScript/Components/LogEntry/_Shared/components.log-entry.js").
                    Include("~/TypeScript/Components/LogEntry/_Shared/notifcationProjectLogEntryViewmodel.js")
                    .IncludeDirectory("~/TypeScript/Components","*.js",true)
                           .IncludeDirectory("~/TypeScript/Services", "*.js", true);

                picbundle.Orderer = new FirstBundelOrder();
    bundles.Add(picbundle);
    }
    }
Chandan Rai
  • 9,879
  • 2
  • 20
  • 28
asad3dsfd3
  • 11
  • 5
  • I use the same custom implementation but I list each resource discretely. I have not tried to wildcard when I needed a specific order. You might also spit the bundle(s) to have even more control over the load order. – Jasen Aug 30 '17 at 19:53
  • should anything else goes into OrderFiles .is it just return files; @Jasen becuase I'm just wrting that. – asad3dsfd3 Aug 30 '17 at 20:10
  • Mine looks exactly like [this](https://stackoverflow.com/a/38741085/2030565). – Jasen Aug 30 '17 at 20:31

0 Answers0