Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Commit d76b013

Browse files
WebpackDevMiddleware now uses ProjectPath option consistently. Fixes #307
1 parent 7c316d5 commit d76b013

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public static void UseWebpackDevMiddleware(
4242
// as fast as some theoretical future alternative.
4343
var nodeServicesOptions = new NodeServicesOptions(appBuilder.ApplicationServices);
4444
nodeServicesOptions.WatchFileExtensions = new string[] {}; // Don't watch anything
45+
if (!string.IsNullOrEmpty(options.ProjectPath))
46+
{
47+
nodeServicesOptions.ProjectPath = options.ProjectPath;
48+
}
49+
4550
var nodeServices = NodeServicesFactory.CreateNodeServices(nodeServicesOptions);
4651

4752
// Get a filename matching the middleware Node script
@@ -50,11 +55,9 @@ public static void UseWebpackDevMiddleware(
5055
var nodeScript = new StringAsTempFile(script); // Will be cleaned up on process exit
5156

5257
// Tell Node to start the server hosting webpack-dev-middleware
53-
var hostEnv = (IHostingEnvironment)appBuilder.ApplicationServices.GetService(typeof(IHostingEnvironment));
54-
var projectPath = options.ProjectPath ?? hostEnv.ContentRootPath;
5558
var devServerOptions = new
5659
{
57-
webpackConfigPath = Path.Combine(projectPath, options.ConfigFile ?? DefaultConfigFile),
60+
webpackConfigPath = Path.Combine(nodeServicesOptions.ProjectPath, options.ConfigFile ?? DefaultConfigFile),
5861
suppliedOptions = options
5962
};
6063
var devServerInfo =

0 commit comments

Comments
 (0)