asp.netasp.net-mvcbundlesystem.web.optimization

Bundle enable optimizations


When i enable my BundleTable.EnableOptimizations in my mvc project for my javascript files it doesn't load any of the files. I'm not getting any errors as well. It simply won't load any of my files.

This is my bundle:

bundles.Add(new ScriptBundle("~/Content/javascripts").Include(
                    "~/Content/js/custom.js",
                    "~/Content/js/customizer.js",
                    "~/Content/js/main.js",
                    "~/Content/js/bootstrap.js",
                    "~/Content/js/jquery-ui-min.js",
                    "~/Content/js/bootstrap-switch-min.js"
                    ));

And in my view:

@Scripts.Render("~/Content/javascripts")

All the files do exist, because when i disable the optimizations it works fine again.


Solution

  • It might be mistaking your virtual path ~/Content/javascripts for a real path. Try this instead.

    bundles.Add(new ScriptBundle("~/bundles/javascripts").Include(
                    "~/Content/js/custom.js",
                    "~/Content/js/customizer.js",
                    "~/Content/js/main.js",
                    "~/Content/js/bootstrap.js",
                    "~/Content/js/jquery-ui-min.js",
                    "~/Content/js/bootstrap-switch-min.js"
                    ));
    

    And in your view.

    @Scripts.Render("~/bundles/javascripts")