I'm playing around with the new ASP.NET bundling feature and can't seem to get my custom ordering to work. Here are my JS files:
bootstrap.js
bootstrap.min.js
jquery-1.7.2.intellisense.js
jquery-1.7.2.js
jquery-1.7.2.min.js
jquery-ui-1.8.19.js
jquery-ui-1.8.19.min.js
jquery.unobtrusive-ajax.js
jquery.unobtrusive-ajax.min.js
I would like the bundler to output boostrap*.js before all the jQuery files. I understand that internally the bundler will sort jQuery files on top so i tried to overrride the logic without success:
var bootstrapOrdering = new BundleFileSetOrdering("bootstrap");
bootstrapOrdering.Files.Add("bootstrap*.js");
bootstrapOrdering.Files.Add("jquery*.js");
BundleTable.Bundles.FileSetOrderList.Add(bootstrapOrdering);
Note: I would prefer to use wildcard if possible to cover all the cases without specifying all the files in code.
Does anyone know i can apply the custom order?
Thanks
You almost had it, the small thing that you missed was just inserting your ordering at the front of the list.
BundleTable.Bundles.FileSetOrderList.Add(bootstrapOrdering);
should be:
BundleTable.Bundles.FileSetOrderList.Insert(0, bootstrapOrdering).
As a result you actually don't need to specify jquery*.js in your ordering, you only need to add your ordering and bootstrap*.js will be prioritized ahead of the built in jquery ordering.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With