3

I'm trying to add a bundled folder so I don't have to manually add each new .less file to the usual bundles, but I don't know how to render it out.

In the BundleConfig,

 BundleTable.Bundles.Add(new DynamicFolderBundle("Content/autobundled", "*.less", new LessTransform(), new CssMinify()));
//.less sheets are at Content/autobundled/example.less 

In the Razor page:

 @Styles.Render("Content/autobundled")

Output:

<link href="/Binky.Web/Content/autobundled" rel="stylesheet">

But that doesn't link any files, just links to the directory which isn't browsable. The articles I read don't say anything about how to use the folder bundles after you create them.

Kal_Torak
  • 2,532
  • 1
  • 21
  • 40

1 Answers1

5

Found the answer here

Basically create the bundle, where the first parameter is the name (not the path) for the bundle,

bundles.Add(new DynamicFolderBundle("less", "*.less", new LessMinify()));

And render them by choosing a path, and use the bundle name appended to the path to say, "get all the files specified in this named bundle from this path".

@Styles.Render("~/Content/autobundled/less")
Kal_Torak
  • 2,532
  • 1
  • 21
  • 40
  • I'm also using it : `bundles.Add(new DynamicFolderBundle("userScripts", "*.js",new JsMinify()).Include("~/Scripts/YGeneral.js").Include("~/Scripts/ZGeneral.js"))` .But for some reason first it puts the script from the `DynamicFolderBundle` output , and THEN it puts the other `Includes`. How can I first put the `Includes` and THEN the `DynamicFolderBundle` ? – Royi Namir Sep 08 '15 at 16:44