JuniorThree
JuniorThree

Reputation: 143

Initialize bundles and minifications from web.config

As you probably know ASP.NET has an opportinity called Bundles and Minification. It allows to join scripts and styles to bundles and to minificate them. But if i want to use it i have to initialize my bundles from BundleConfig.cs and to register them from Application_Start. Can i do it in web.config or is it impossible?

Upvotes: 0

Views: 964

Answers (1)

CodeCaster
CodeCaster

Reputation: 151674

You can't. You can only enable or disable bundling from config.

If you want this because you want to be able to alter files in production without having to open Visual Studio and without having to follow a proper release cycle (which you shouldn't), you can simply create bundles that include all files:

bundles.Add(new StyleBundle("~/bundles/css")
                .Include("~/Content/*.css"));

bundles.Add(new ScriptBundle("~/bundles/js")
                .Include("~/Scripts/*.js"));

Then you can add and remove files from those directories as you please.

See Include all files in a folder in a single bundle to also include subdirectories.

Upvotes: 1

Related Questions