ligershark / WebOptimizer

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

Wrong file provider selected in class AssetExtensions.GetFileProvider #222

Open Schaeri opened 2 years ago

Schaeri commented 2 years ago

With the commit „FIX ASP.NET Core 6 default file provider” the retrieval of the file provider was changed, which lead to bugs when not all files are located in the wwwroot of the main application.

We host a blazor wasm application inside kestrel which use several helper libraries and also contains js and css files. With the newest version (3.0.357) the default composite file provider is no longer used. Instead the GetFileProvider method tries to create a PhysicalFileProvider and tries to find all files on one physical place, which is incorrect in a scenario we have. The usage of the Composite provider would be correct.

Our question is now, can this be changed back to the old behavior? Or can you help us to adapt the configuration so that the WebOptimizer will also work in a scenario where you have files in a lot of locations and projects?

Thanks a lot for the help.

Schaeri commented 2 years ago

What also would work in our case is to change the GetFileProvider method as following:

public static IFileProvider GetFileProvider(this IAsset asset, IWebHostEnvironment env)
{
    return asset.GetCustomFileProvider(env) ??
           (env.WebRootFileProvider is CompositeFileProvider && !string.IsNullOrEmpty(env.WebRootPath))
               ? new PhysicalFileProvider(env.WebRootPath)
               : env.WebRootFileProvider);
}
ElenaUkhova commented 2 years ago

We faced a similar problem. We are looking forward to a fix.