My day of web development was in .net 3 or 4, now I am trying to upgrade my skill bit.
So, I installed .net core 2.1.5 and react template, then created a react project in visual studio. However there are some basic things I am struggling with:
In startup.cs, I have following lines:
app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseReactDevelopmentServer(npmScript: "start"); } });
It is recommended that spa.UseReactDevelopmentServer(npmScript: "start"); should be just for development environment, so what should I do in production environment?
If I just comment out this line, it will throw errors
An unhandled exception occurred while processing the request. InvalidOperationException: The SPA default page middleware could not return the default page '/index.html' because it was not found, and no other middleware handled the request.
- When running the project, from the source of index.html, I can see this line was added at the end of the page.
<script type="text/javascript" src="/static/js/bundle.js"></script>.
So who added this line? Is it the embedded react development server or it is actually the build process? As I see these lines in packages.json, so I am guessing it is the npm build that created the bundle? If that is the case, how do I tell it not to bundle the js and I would to do some debugging in chrome to learn the code.
"scripts": {
"start": "rimraf ./build && react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}