Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you serve static files ? #22

Closed
valeriob opened this issue Feb 26, 2018 · 4 comments
Closed

How do you serve static files ? #22

valeriob opened this issue Feb 26, 2018 · 4 comments

Comments

@valeriob
Copy link

I think a feature folder is not complete with some static content, how do you serve it without copying to wwwroot ? I'm following this approach
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files?tabs=aspnetcore2x#serve-static-files

app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider( Path.Combine(Directory.GetCurrentDirectory(), "MyStaticFiles")), RequestPath = "/StaticFiles" });

But it only works if the file system path starts with a different char than the request path or it will not allow to have any routing parameter in the request.

@OdeToCode
Copy link
Owner

The problem with serving content from feature folders and other areas of the project is that you'd need to put safeguards in place to make sure you don't send your source code and configuration files back to the client.

@valeriob
Copy link
Author

Yes i agree.
Do you have any experience on reasonable size production project with feature folders ? I mean the need of static files comes out quite fast on a common application, how did you combine static files serving and features folders ?

@OdeToCode
Copy link
Owner

I have experience with large projects in production using feature folders. We have two types of static content:

  1. Images, scripts, and stylesheets that are common to several feature areas of the application. These live in folders underneath a directory like wwwroot that only exists for static content.

  2. Scripts and stylesheets that are specific to a feature. We use webpack during the build to collect all these assets (transpile and bundle) and place them into a static only content directory like wwwroot.

So in the end, static content might live in feature folders, but never served from those folders.

@valeriob
Copy link
Author

Thank you 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants