WebOptimizer
WebOptimizer copied to clipboard
FileNotFoundException
I followed the sample and added a single JS file for minification:
services.AddWebOptimizer(pipeline => { pipeline.MinifyJsFiles("Scripts/r/react.js"); });
However, accessing https://localhost:44393/Scripts/r/react.js results in:
FileNotFoundException: The file /Scripts/r/react.js does not exist.
But Process Monitor shows me that the file was read succesfully:

Other files next to react.js which are no configured for minification, e.g. https://localhost:44393/Scripts/r/jquery.js can be accessed successfully. The path thus seems to be correct. So what might be the problem?
Digging through the code, If found out that the problem was that I do not have a wwwroot. So I needed UseContentRoot which can be used for MinifyJsFiles like this:
pipeline.MinifyJsFiles("Script/r/react.js").ToList().ForEach(p => p.UseContentRoot());
Please consider adding this to README.md.
Please also consider after
https://github.com/ligershark/WebOptimizer/blob/8b26040c86a24444d1bfa4d05694611f38be5238/src/WebOptimizer.Core/Asset.cs#L141
raising a more specified error message if !file.Exists, e.g. "The file /Scripts/r/react.js does not exist in searched folders: X, Y, Z"