In the .net core, the so-called middleware processor and the contents of the wwwroot folder in the project should not be used to process any request. To do this, you connect one of the extensions, for example, UseStaticFiles in your startup.cs. If there is middleware, then there is an output stream that can be modified at its discretion before sending to the client (for example, this is how middleware works by dynamically compressing the response).
All you need to do is correctly replace the outgoing stream provided by the .net core infrastructure with the class you have inherited from the standard class Stream, get all the data (in your case it is a js file), find all the places where a replacement is needed (mark them with a unique combination, for example _____please_replace_me_1_____ ), substitute your values and send the result to the original stream (which you prudently saved in the class instance of your stream).
It sounds simple, but in fact you need to take into account many details that are not so obvious. The best solution is to see how the middleware I wrote is written by Microsoft itself (since recently the source can be found on github, for example, https://github.com/aspnet/StaticFiles , and also here https://github.com/aspnet/BasicMiddleware /tree/dev/src/Microsoft.AspNetCore.ResponseCompression ).
After examining the sources, you can try to create your own solution, which I did https://github.com/bopohaa/ResponseProxy This extension allows you to replace one word in a static js file before giving it to the client.
I hope I helped you.
<httpHandlers><add verb="*" path="*.js" type="YourJsHandler"/> `read the file yourself, rework as you like. Is this mechanism for you to show? Here is the "scratch" is msdn.microsoft.com/ru-ru/library/ms228090(v=vs.100).aspx - nick_n_a