ASP.NET Core + React | Correct way to structure files

1000 Views Asked by At

What is the correct way to structure files in real life application?

By default, if I'm correct, ASP.NET Core projects files should be structured as:

[Solution]

  • [Project]
    • Dependencies
    • Properties
    • Controllers
    • Models
    • Repositories
    • wwwroot
    • Pages
    • Startup.cs
    • Program.cs
    • appsettings.json

For any static file it should be inside a wwwroot folder, right?

But then why creating a ASP.NET Core project with React + redux template makes a folder 'ClientApp' instead of 'wwwroot' and places all react code in there with folders 'src' 'public'?

I know that you can do that and then in startup.cs enable it with 'app.UseSpaStaticFiles();', But why? Is it just to make it simpler or does it have real life benefits? Should I structure my files same way too?

And if I suppose, or can, use with 'wwwroot', how should wwwroot folder look? I know that wwwroot folder suppose to contain all the static files such as css, images and js

wwwroot

  • css
  • js
  • images

Since react is a js library/framework, should all code be inside js folder like this

wwwroot

  • css
  • js
    • src
      • actions
      • components
      • store
      • ...
  • images

I been trying to find an answer but everywhere everyone has a different answer.

On a side note, also if using scss, or similar, should all the scss be inside css folder or should there be a scss folder inside wwwroot that on compile saves css code inside css folder?

0

There are 0 best solutions below