Skip to content

Instantly share code, notes, and snippets.

@boban100janovski
Last active May 25, 2016 00:09
Show Gist options
  • Save boban100janovski/b456aea4831aff7dbfc144039984e43c to your computer and use it in GitHub Desktop.
Save boban100janovski/b456aea4831aff7dbfc144039984e43c to your computer and use it in GitHub Desktop.
asp.net core rc2, serve node_modules folder
using Microsoft.Extensions.PlatformAbstractions;
using System.IO;
using Microsoft.Extensions.FileProviders;
using Microsoft.AspNetCore.Hosting;
namespace Microsoft.AspNetCore.Builder
{
public static class ApplicationBuilderExtensions
{
public static IApplicationBuilder UseNodeModules(
this IApplicationBuilder app,
IHostingEnvironment env)
{
var path = Path.Combine(env.ContentRootPath, "node_modules");
var provider = new PhysicalFileProvider(path);
var options = new StaticFileOptions();
options.RequestPath = "/node_modules";
options.FileProvider = provider;
app.UseStaticFiles(options);
return app;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment