Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC 4 ScriptBundle returns empty

Specifically, I am trying to create a ScriptBundle in MVC 4 with already minified scripts, and return this same Bundle whether the project is in Debug or not.

My web project references the MVC Telerik Grid NuGet package. In that package, Telerik only provides the minified JS files. Bundling code is below.

        // telerik scripts
        bundles.Add(new ScriptBundle("~/scripts/bundles/telerik").Include(
            "~/Scripts/2012.1.214/telerik.common.min.js",
            "~/Scripts/2012.1.214/telerik.textbox.min.js",
            "~/Scripts/2012.1.214/telerik.calendar.min.js",
            "~/Scripts/2012.1.214/telerik.datepicker.min.js",
            "~/Scripts/2012.1.214/telerik.grid.min.js",
            "~/Scripts/2012.1.214/telerik.grid.filtering.min.js"));

Other ScriptBundles run fine, but when my project attempts to reference this bundle, the request appears as: scripts/bundles/telerik?v= Returning nothing.

If I set BundleTable.EnableOptimizations = true, then it DOES return the ScriptBundle and references a specific version, however this solution is unacceptable.

I do not want to forcibly set BundleTable.EnableOptimizations = true, since I want all other Bundles to return the non-minified versions when appropriate.

Anyone have a similar experience and if so, what was the solution?

like image 778
Joshua Avatar asked Sep 24 '12 16:09

Joshua


1 Answers

I think you have the same problem, please look at this link: mvc4 bundler not including .min files

Either rename .min.js to .js or do something like:

    public static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
    {
        if (ignoreList == null)
            throw new ArgumentNullException("ignoreList");

        ignoreList.Clear();

        ignoreList.Ignore("*.intellisense.js");
        ignoreList.Ignore("*-vsdoc.js");
        ignoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled);
        //ignoreList.Ignore("*.min.js", OptimizationMode.WhenDisabled);
        ignoreList.Ignore("*.min.css", OptimizationMode.WhenDisabled);
    }
like image 133
webdeveloper Avatar answered Oct 21 '22 17:10

webdeveloper