WebpackDevMiddleware now uses ProjectPath option consistently. Fixes #307

This commit is contained in:
SteveSandersonMS
2016-09-14 12:04:15 +01:00
parent 7c316d5c74
commit d76b013a56

View File

@@ -42,6 +42,11 @@ namespace Microsoft.AspNetCore.Builder
// as fast as some theoretical future alternative. // as fast as some theoretical future alternative.
var nodeServicesOptions = new NodeServicesOptions(appBuilder.ApplicationServices); var nodeServicesOptions = new NodeServicesOptions(appBuilder.ApplicationServices);
nodeServicesOptions.WatchFileExtensions = new string[] {}; // Don't watch anything nodeServicesOptions.WatchFileExtensions = new string[] {}; // Don't watch anything
if (!string.IsNullOrEmpty(options.ProjectPath))
{
nodeServicesOptions.ProjectPath = options.ProjectPath;
}
var nodeServices = NodeServicesFactory.CreateNodeServices(nodeServicesOptions); var nodeServices = NodeServicesFactory.CreateNodeServices(nodeServicesOptions);
// Get a filename matching the middleware Node script // Get a filename matching the middleware Node script
@@ -50,11 +55,9 @@ namespace Microsoft.AspNetCore.Builder
var nodeScript = new StringAsTempFile(script); // Will be cleaned up on process exit var nodeScript = new StringAsTempFile(script); // Will be cleaned up on process exit
// Tell Node to start the server hosting webpack-dev-middleware // Tell Node to start the server hosting webpack-dev-middleware
var hostEnv = (IHostingEnvironment)appBuilder.ApplicationServices.GetService(typeof(IHostingEnvironment));
var projectPath = options.ProjectPath ?? hostEnv.ContentRootPath;
var devServerOptions = new var devServerOptions = new
{ {
webpackConfigPath = Path.Combine(projectPath, options.ConfigFile ?? DefaultConfigFile), webpackConfigPath = Path.Combine(nodeServicesOptions.ProjectPath, options.ConfigFile ?? DefaultConfigFile),
suppliedOptions = options suppliedOptions = options
}; };
var devServerInfo = var devServerInfo =