Include all files in a folder in a single bundle
58,825
Use the overload of IncludeDirectory method which accepts bool searchSubdirectories
as third parameter.
MSDN:
searchSubdirectories - Specifies whether to recursively search subdirectories of directoryVirtualPath.
Example:
bundles.Add(new ScriptBundle("~/bundles/scripts")
.IncludeDirectory("~/Scripts", "*.js", true));
Related videos on Youtube
Author by
Jordan Axe
Updated on July 16, 2022Comments
-
Jordan Axe almost 2 years
When using
BundleConfig
is it possible to include all files of a folder including all the files of the childfolders (and their childfolders etc.)?I found
.IncludeDirectory()
but it seems to only include the files of the folder itself, not the files of the subfolders. -
Shaiju T over 8 yearscan we order the files in the directory as done here ?
-
Shaiju T over 8 yearsthis doesn't including
.min
files, is there a solution ? , cause i have.min
and.js
files in the folder -
Zabavsky over 8 years@stom, min files are usually included by the bundles in the release mode.
-
Shaiju T over 8 yearsyes you are correct as mentioned here , i have changed the
web.config
to<compilation debug="false">
and inBundleConfig.cs
addedBundleTable.EnableOptimizations = true;
thank you. -
Michael over 8 years@Zabavsky, There is a bug in Web.Optimization version 1.1 in which your answer doesn't work, but updating to the latest version or downgrading to 1.0 will fix it. Might want to add that to your answer to save people some time. stackoverflow.com/questions/22612157/…