@@ -35,15 +35,25 @@ public static void UseWebpackDevMiddleware(
3535 "To enable ReactHotModuleReplacement, you must also enable HotModuleReplacement." ) ;
3636 }
3737
38+ string projectPath ;
39+ if ( options . ProjectPath == null )
40+ {
41+ var hostEnv = ( IHostingEnvironment ) appBuilder . ApplicationServices . GetService ( typeof ( IHostingEnvironment ) ) ;
42+ projectPath = hostEnv . ContentRootPath ;
43+ }
44+ else
45+ {
46+ projectPath = options . ProjectPath ;
47+ }
48+
3849 // Unlike other consumers of NodeServices, WebpackDevMiddleware dosen't share Node instances, nor does it
3950 // use your DI configuration. It's important for WebpackDevMiddleware to have its own private Node instance
4051 // because it must *not* restart when files change (if it did, you'd lose all the benefits of Webpack
4152 // middleware). And since this is a dev-time-only feature, it doesn't matter if the default transport isn't
4253 // as fast as some theoretical future alternative.
43- var hostEnv = ( IHostingEnvironment ) appBuilder . ApplicationServices . GetService ( typeof ( IHostingEnvironment ) ) ;
4454 var nodeServices = Configuration . CreateNodeServices ( new NodeServicesOptions
4555 {
46- ProjectPath = hostEnv . ContentRootPath ,
56+ ProjectPath = projectPath ,
4757 WatchFileExtensions = new string [ ] { } // Don't watch anything
4858 } ) ;
4959
@@ -55,7 +65,7 @@ public static void UseWebpackDevMiddleware(
5565 // Tell Node to start the server hosting webpack-dev-middleware
5666 var devServerOptions = new
5767 {
58- webpackConfigPath = Path . Combine ( hostEnv . ContentRootPath , options . ConfigFile ?? DefaultConfigFile ) ,
68+ webpackConfigPath = Path . Combine ( projectPath , options . ConfigFile ?? DefaultConfigFile ) ,
5969 suppliedOptions = options
6070 } ;
6171 var devServerInfo =
0 commit comments