Search code examples
c#.net-corebundling-and-minification

.NET core BundlerMinifier wrong order of files


I am using BundlerMinifier for .NET core 2.1 but i cannot set correct order of bundling files.

I have following files in wwwroot/js/Lib/:

1.jquery.min.js
2.jquery.ui.min.js
3.server.js

After bundling this files are sorted within a site.js file in specified order:

2.jquery.ui.min.js
3.server.js
1.jquery.min.js

Page do not load because jquery ui is loaded before jquery. I have not found any solution in documentation. Am I missing something?

This is my bundleconfig.json file:

[
  {
    "outputFileName": "wwwroot/js/site-lib.min.js",
    "inputFiles": [
      "wwwroot/js/Lib/"
    ],
    // Optionally specify minification options
    "minify": {
      "enabled": false,
      "renameLocals": true
    }
  }
]

Solution

  • I had a similar problem regarding the BundlerMinifier and the order it was reading the files. My solution was to remove the old bundle.js and bundleconfig.json and rebundle everything. What I did differently was that I excluded (in my case jquery-3.3.1.js) from the bundle and bundled everyhing else. After that I first included the jQuery-3.3.1.js and after that the bundle.js.

    <script src="~/js/jquery-3.3.1.js"></script
    <script src="~/js/bundle.js"></script>
    

    Hope this helps :)