Skip to content

Commit bd69cb7

Browse files
author
Matt Cole
committed
Add Node project path to webpack middleware options
1 parent 2a6465b commit bd69cb7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Microsoft.AspNetCore.SpaServices/Webpack/WebpackDevMiddleware.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ public static void UseWebpackDevMiddleware(
4141
// middleware). And since this is a dev-time-only feature, it doesn't matter if the default transport isn't
4242
// as fast as some theoretical future alternative.
4343
var hostEnv = (IHostingEnvironment)appBuilder.ApplicationServices.GetService(typeof(IHostingEnvironment));
44+
var projectPath = options.ProjectPath ?? hostEnv.ContentRootPath;
4445
var nodeServices = Configuration.CreateNodeServices(new NodeServicesOptions
4546
{
46-
ProjectPath = hostEnv.ContentRootPath,
47+
ProjectPath = projectPath,
4748
WatchFileExtensions = new string[] { } // Don't watch anything
4849
});
4950

@@ -55,7 +56,7 @@ public static void UseWebpackDevMiddleware(
5556
// Tell Node to start the server hosting webpack-dev-middleware
5657
var devServerOptions = new
5758
{
58-
webpackConfigPath = Path.Combine(hostEnv.ContentRootPath, options.ConfigFile ?? DefaultConfigFile),
59+
webpackConfigPath = Path.Combine(projectPath, options.ConfigFile ?? DefaultConfigFile),
5960
suppliedOptions = options
6061
};
6162
var devServerInfo =

src/Microsoft.AspNetCore.SpaServices/Webpack/WebpackDevMiddlewareOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ public class WebpackDevMiddlewareOptions
66
public int HotModuleReplacementServerPort { get; set; }
77
public bool ReactHotModuleReplacement { get; set; }
88
public string ConfigFile { get; set; }
9+
public string ProjectPath { get; set; }
910
}
1011
}

0 commit comments

Comments
 (0)