24

Hi Can anyone give me an example on how to use Scriptbundle method IncludeDirectory for Javascripts, not able to get how to write the search pattern string , Is it regex?

bundles.Add(new ScriptBundle("~/bundles/customjs").IncludeDirectory(
                "~/Scripts/Custom",?);
freshbm
  • 5,540
  • 5
  • 46
  • 75
Rameez Ahmed Sayad
  • 1,300
  • 6
  • 16
  • 29
  • 1
    Here are some other examples / explanation from a related [SO Post](http://stackoverflow.com/questions/14563415/force-asp-net-mvc-bundle-to-render-the-javascript-files-in-a-certain-order/14563828#14563828). – MikeSmithDev Mar 25 '13 at 14:43
  • Thanks Mike , the example gives more information – Rameez Ahmed Sayad Mar 25 '13 at 17:15

1 Answers1

40

You can write like this:

bundles.Add(new ScriptBundle("~/bundles/customjs").IncludeDirectory(
                "~/Scripts/Custom","*.js"));

If you want for example javascript.

You can read more here: http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification

freshbm
  • 5,540
  • 5
  • 46
  • 75
  • 1
    Why will the above also include files that end with .coffee? Should it not send only *.js? – bob Nov 22 '14 at 17:04
  • 1
    If you need certain files from the folder to be included before others, you can specify them separately with Include (called before IncludeDirectory) , even though they will be picked by the "*.js" search pattern as well - the system is smart enough to include them only once. – Zar Shardan Oct 29 '16 at 01:07