2

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 DevTools3

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

14 Comments

Hi @Martin Staufcik But now everyone can go through my components in DevTools when I deploy my production app?
DevTools can probably detect it is running from localhost and find the location from where the web is running. This will not happen on for a site deployed to web server.
But I also tried to publish production build app on real host server. In my ClientApp there is only build folder with generated files (without my visible components). But I can still find all components in DevTools even when it is normally hosted. Am I doing something wrong?
When the app is published, the ClientApp folder contains a build folder with the compiled distribution files (javascript, css), there are no source files anymore.
Exactly! However.. I took whole published .net core app (without source files in ClientApp) I push it to my hosting FTP and I still can see my components in DevTools .. that is what make me crazy
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.