2

I've read and done the steps in this, this and this post!

Still can not use the Asp.net Bundles!

In Global.asax.cs

BundleConfig.RegisterBundles(BundleTable.Bundles, Server);

and ...

public static void RegisterBundles(BundleCollection bundles, HttpServerUtility server)
{
    bundles.IgnoreList.Clear();
    AddDefaultIgnorePatterns(bundles.IgnoreList);
    ...

    var scriptBundle = new ScriptBundle("~/Scripts")
        .IncludeDirectory("~/Scripts", "*.js");
    bundles.Add(scriptBundle); 

Ignore list

private static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
{
    ignoreList.Ignore("*.intellisense.js", OptimizationMode.Always);
    ignoreList.Ignore("*-vsdoc.js", OptimizationMode.Always);
    ignoreList.Ignore("*.debug.js", OptimizationMode.Always);

    ignoreList.Ignore("underscore.js", OptimizationMode.Always);
    ignoreList.Ignore("moment.js", OptimizationMode.Always);
    ignoreList.Ignore("jquery-{version}.js", OptimizationMode.Always);
}

Still, files like jquery.pnotify.min.js are not rendered!

Packages

WebGrease 1.3.0 Microsoft.AspNet.Web.Optimi... 1.1.0-Beta1

Community
  • 1
  • 1
ridermansb
  • 10,779
  • 24
  • 115
  • 226
  • did you try this .IncludeDirectory("~/Scripts/jquery.pnotify.{version}.js"); – HaBo May 07 '13 at 02:26
  • I added this: `.Include("~/Scripts/jquery.pnotify.min.js")` and it worked! But I can not do this for all scritps with `.min` extension in this folder. The idea IncludeDirectory is precisely this, **get all the script and create the bundle**. – ridermansb May 07 '13 at 02:34
  • I have the exact same problem, I clear the IgnoreList and the min.js files are still ignored! This is driving me mad and I can't find a solution for this. Including each file specifically without any wildcards defeats the whole purpose of bundles. I result to directly include my scripts using normal – MoSs Nov 26 '13 at 14:20

4 Answers4

4

OK! I figured it out! After looking around a bit in BundleTable.Bundles members found a DirectoryFilter apparently you have to Clear() that as well!

So bundles.IgnoreList.Clear(); is not enough (it used to be) now you have to do bundles.DirectoryFilter.Clear(); as well.

It worked for me, I hope that helps.

MoSs
  • 565
  • 1
  • 4
  • 11
0

I would hazard a guess and say that you're running your application in Debug mode and not Release mode. In Debug mode .min files are ignored and it renders the un-minified script to help make debugging easier.

CallumVass
  • 11,288
  • 26
  • 84
  • 154
0

By default, the bundler will ignore files with a .min extension. Min files are preminified, and it is better if you let the optimizer minify the file itself. You should put jquery.pnotify.js in the directory and then it will work just fine for you, delivering a non-minified, non-bundled version while debugging, and a minified and bundled version in release.

You can however, override the default (although I recommend you don't), by clearing the default IgnoreList and DirectoryFiler via bundles.IgnoreList.Clear(); and bundles.DirectoryFilter.Clear();

Robert McKee
  • 21,305
  • 1
  • 43
  • 57
0

In Application_Start:

BundleConfig.RegisterBundles(BundleTable.Bundles);
BundleTable.EnableOptimizations = true;
Daniel
  • 1,044
  • 11
  • 10