clarence_odbody
clarence_odbody

Reputation: 185

MVC JS Bundle not including all files

I've seen questions about this elsewhere but they all were about bundling .min files. In my case I have a couple of js files in a bundle but only one is being included as far as I can see. Everything builds but if I look at the page source or the bundle in chrome developer tools, only one js file is included. Bundle looks like this:

        public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/myJS").Include(
                  "~/myJS/getPathforAjax.js", 
                  "~/myJS/dropdown.js",
                  "~/myJS/email8.js",
                  "~/myJS/main-nav-click.js"
                  ));
        bundles.Add(new StyleBundle("~/Content/css").Include(
                 "~/Content/site.css"
                 ,"~/Content/caption.css"
                 , "~/Content/dropdown.css"
                 , "~/Content/colors.css"
                 , "~/Content/buttons.css"
                 , "~/Content/stripe.css"));
    }

The css files all load but in the myJS bundle only email8 looks to be included and it is minimized. I would think that if there was a js error then none of the files would show or they would show non-minimized All the files are where they are supposed to be on the server. I have reloaded, hard reloaded, etc, but they don't pop up.

Any ideas?

Upvotes: 0

Views: 1208

Answers (1)

jishan siddique
jishan siddique

Reputation: 1893

Please refer this Link

and try this code it's work for me in my project very first I'm adding min file in bundles it's not including then I'm added this line.

BundleTable.EnableOptimizations = true;

 public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/myJS").Include(
                  "~/myJS/getPathforAjax.js", 
                  "~/myJS/dropdown.js",
                  "~/myJS/email8.js",
                  "~/myJS/main-nav-click.js"
                  ));
        bundles.Add(new StyleBundle("~/Content/css").Include(
                 "~/Content/site.css"
                 ,"~/Content/caption.css"
                 , "~/Content/dropdown.css"
                 , "~/Content/colors.css"
                 , "~/Content/buttons.css"
                 , "~/Content/stripe.css"));

         // Code removed for clarity.
          BundleTable.EnableOptimizations = true;
    }

Upvotes: 1

Related Questions