On localhost: This behavior of displaying source files in DevTools is probably just a feature of DevTools to make debugging easier in this tool. DevTools can detect it is running from localhost and find the location from where the web is running. That is why it can find the source files (ts, tsx, or jsx files).
When published: The published application does not contain source files anymore (ts, tsx, jsx). These source files are compiled into distribution js files in the ClientApp/build
folder. The file structure in the picture was created by the browser based on javascript source map files (.map
files). One solution would be to remove the source map files, but it is ok to leave them there, some arguments for it are in this post:
Source maps files in production - Is it safe?
There are two related lines of code in Startup.cs that configure static files handling.
1) UseStaticFiles - Serve files inside of web root (wwwroot folder).
app.UseStaticFiles();
2) UseSpaStaticFiles - Serve static file like image, css, js in asset folder of angular app
app.UseSpaStaticFiles();
Note. The folder wwwroot
is not created by default when a new project is created from the React.js and Redux template. It can be added into the project and then it serves static files it contains.