I am migrating a .NET Framework project to .NET 6.
Old bundling logic in .NET framework had the below code:
#if DEBUG
BundleTable.EnableOptimizations = false;
#else
BundleTable.EnableOptimizations = true;
#endif
I believe, the code above disables bundling for DEBUG mode & enables it for RELEASE mode?
In .NET 6, I am using WebOptimizer for bundling.
Is there a similar option or setting in WebOptimizer as well?
So actually, this is not specific to .NET 6. I believe you may use something like this.
#if DEBUG
// just do not add web optimizer code
#else
app.UseWebOptimizer();
#endif
Also in documentation there is something like this:
Disabling minification: If you want to disable minification (e.g. in development), the following overload for AddWebOptimizer() can be used:
if (env.IsDevelopment())
{
services.AddWebOptimizer(minifyJavaScript:false,minifyCss:false);
}
https://github.com/ligershark/WebOptimizer
Regarding to your code in answer below, it is better to do like this:
public void Configure(WebApplication app, IWebHostEnvironment env)
{
if (app.Environment.IsDevelopment())
{
app.UseWebOptimizer();
}
app.UseHsts();
app.UseHttpsRedirection();
app.Run();
}