ligershark / WebOptimizer

A bundler and minifier for ASP.NET Core
Apache License 2.0
753 stars 113 forks source link

Feature Request for in code configuration #255

Closed Schaeri closed 1 year ago

Schaeri commented 1 year ago

Use Case

All our projects use the same Web Optimizer settings. To align the configurations and make sure the configuration will not be adapted, removed or changed in the productive environments of all applications, we like to have the ability to define the settings for the Web Optimizer directly when calling the AddWebOptimizer service extension. The call to the extension is encapsulated in a global nuget for all project, pre add all general js files like file download, bootstrapping etc.

Code Changes PR:

Via the AddWebOptimizer extension you can directly configure the web optimizer options:

services.AddWebOptimizer(pipeline => 
    { 
        pipeline.AddCssBundle("/css/bundle.css", "css/*.css"); 
        pipeline.AddJavaScriptBundle("/js/bundle.js", "js/plus.js", "js/minus.js"); 
    }, 
    option => 
    { 
        option.EnableCaching = true; 
        option.EnableDiskCache = false; 
        option.EnableMemoryCache = true; 
        option.AllowEmptyBundle = true; 
    }); 

Every extension now supports the direct configuration via code. There are no breaking changes.

The Readme was adapted.

Let me know if this PR has a change to get merged into main. If I there are any wishes for corrections let me know. Then we try to adapt the code as fast as possible.

madskristensen commented 1 year ago

Thank you!

Schaeri commented 1 year ago

Thanks a lot.