Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rendering DynamicFolderBundle?

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.

like image 449
Kal_Torak Avatar asked Dec 04 '25 18:12

Kal_Torak


1 Answers

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")
like image 73
Kal_Torak Avatar answered Dec 06 '25 12:12

Kal_Torak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!