Reputation: 125
I created new project in VS - ASP.NET Core Web Application. I used Core 3.1 + React.js and Redux template. When I run this project in ISS Express (Debug/Release) I am able to see all individual files from src in DevTools. I am doing something wrong? I thought that src files shouldn't be visible. Do I need to set some parameters or something like that? I try to also publish and deploy this on real IIS and result is basically the same.. I can see all from src folder.
Thank You!
Visual Studio 16.5.1
DevTools
HostedFiles+DevTools
Upvotes: 2
Views: 1708
Reputation: 9490
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.
Upvotes: 1