What if we start by creating a brand new project that follows the MVC pattern? Instead of choosing an 'empty' template, opt for the MVC option. Then, navigate to App_Start/BundleConfig.cs and replicate that file exactly as shown. Register it just like the default project does in the global.asax.cs file.
In global.asax.cs:
BundleConfig.RegisterBundles(BundleTable.Bundles);
App_Start/BundleConfig.cs:
using System.Web;
using System.Web.Optimization;
namespace WebApplication1
{
public class BundleConfig
{
// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate*"));
// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/respond.js"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/site.css"));
}
}
}
However, for a more efficient approach, consider utilizing Node-based tools like webpack or gulp. While bundles can be used, they may not offer the same level of power and flexibility found in front-end builds using these tools. They can assist in ensuring the correct load order, among other things.