ApplicationBuilderExtensions
.Net Core use package.json files
Source
public static class ApplicationBuilderExtensions
{
public static IApplicationBuilder UseNodeModules(this IApplicationBuilder app, string root)
{
var path = Path.Combine(root, "node_modules");
var provider = new PhysicalFileProvider(path);
var options = new StaticFileOptions
{
RequestPath = "/node_modules",
FileProvider = provider
};
app.UseStaticFiles(options);
return app;
}
}
Example
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseNodeModules(env.ContentRootPath);
}