ContentTypeProvider
of theStaticFileOptions
, the default one doesn't include scss
fileProvider.GetDirectoryContents("/SecretCircle.BmwTheme/wwwroot/scripts/app.js");
It depends on how you init the fileProvider, e.g. we have a `ModuleEmbeddedStaticFileProvider
that return nothing on GetDirectoryContents()
, and we have a ModuleEmbeddedFileProvider
that implements it. The paths of an embedded file is e.g. Areas/TheModule/subpath
, subpath being e.g. wwwroot/style/style.css
. I will try your use case with an scss file soon ;)
`
https://localhost:44364/SecretCircle.BmwTheme/scripts/pages/main.js
fileProvider.GetDirectoryContents("Areas/SecretCircle.BmwTheme/scripts/app.js")
- 0 results
StaticFileOptions
in place of collaborating to its configuration, so that you keep its file provider that we compose with the content root file provider and our embedded file rpoviders, i will show you the code i used in the main startup
public override void Configure(IApplicationBuilder app, IEndpointRouteBuilder routes, IServiceProvider serviceProvider)
{
var contentTypeProvider = serviceProvider.GetRequiredService<IContentTypeProvider>() as FileExtensionContentTypeProvider;
contentTypeProvider.Mappings.Add(".scss", "text/scss");
}
What if I do this in a module?
IContentTypeProvider
on Orchard startup
StaticFileMiddleware
grab it from the options, not through the DI https://github.com/dotnet/aspnetcore/blob/master/src/Middleware/StaticFiles/src/StaticFileMiddleware.cs#L59
Just tried directly from the embedded file provider, you need to inject IApplicationContext
var fileProvider = new ModuleEmbeddedFileProvider(_applicationContext);
var test1 = fileProvider.GetDirectoryContents("/Areas/TheBlogTheme/scss/_footer.scss");
var test2 = fileProvider.GetFileInfo("/Areas/TheBlogTheme/scss/_footer.scss");
The first line on test1 returns nothing, normal ;)
The second line on test 2 returns the requested file info
The file provider that we compose is set in place of the content root file provider, i will show you how to retrieve it from the hosting environment
fileProvider
is composite file rpovider
/Areas/SecretCircle.BmwTheme/wwwroot/scripts/app.js
becomes /SecretCircle.BmwTheme/scripts/app.js
?