Base solution for your next web application
Open Closed

Exclude some bundle .js file #5168


User avatar
0
tteoh created

I'm using MVC5 AJ1 platform.

I found this code in AppBundleConfig.cs: [attachment=0:2hf37p0e]Capture.PNG[/attachment:2hf37p0e]

This method is use to include all App folder with .js pattern right? Therefore, I'm wondering how to exclude specific .js files in App folder?

Thanks. /Tommy


1 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    Hi,

    You can use IgnoreList Class:

    • <a class="postlink" href="https://docs.microsoft.com/en-us/previous-versions/aspnet/web-frameworks/jj646573(v=vs.110">https://docs.microsoft.com/en-us/previo ... 3(v=vs.110</a>)
    • <a class="postlink" href="https://weblogs.asp.net/imranbaloch/hidden-options-of-asp-net-bundling-and-minification">https://weblogs.asp.net/imranbaloch/hid ... nification</a>
    • <a class="postlink" href="https://stack247.wordpress.com/2014/04/18/asp-net-mvc-4-bundles-ignore-list/">https://stack247.wordpress.com/2014/04/ ... nore-list/</a>

    See the sample code;

    //APPLICATION
                bundles.IgnoreList.Clear();
                bundles.IgnoreList.Ignore("*.intellisense.js");
                bundles.IgnoreList.Ignore("*-vsdoc.js");
                bundles.IgnoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled);
                bundles.IgnoreList.Ignore("*.min.css", OptimizationMode.WhenDisabled);
    
                bundles.Add(
                    new StyleBundle("~/Bundles/App/css")
                        .IncludeDirectory("~/App", "*.css", true)
                        .ForceOrdered()
                    );
    
    
                bundles.Add(
                    new ScriptBundle("~/Bundles/App/js")
                        .IncludeDirectory("~/App", "*.js", true)
                        .ForceOrdered()
                    );