@@ -40,13 +40,7 @@ public static void UseWebpackDevMiddleware(
40
40
// because it must *not* restart when files change (if it did, you'd lose all the benefits of Webpack
41
41
// middleware). And since this is a dev-time-only feature, it doesn't matter if the default transport isn't
42
42
// as fast as some theoretical future alternative.
43
- var nodeServicesOptions = new NodeServicesOptions ( appBuilder . ApplicationServices ) ;
44
- nodeServicesOptions . WatchFileExtensions = new string [ ] { } ; // Don't watch anything
45
- if ( ! string . IsNullOrEmpty ( options . ProjectPath ) )
46
- {
47
- nodeServicesOptions . ProjectPath = options . ProjectPath ;
48
- }
49
-
43
+ var nodeServicesOptions = CreateNodeServicesOptions ( appBuilder . ApplicationServices , options ) ;
50
44
var nodeServices = NodeServicesFactory . CreateNodeServices ( nodeServicesOptions ) ;
51
45
52
46
// Get a filename matching the middleware Node script
@@ -91,6 +85,26 @@ public static void UseWebpackDevMiddleware(
91
85
} ) ;
92
86
}
93
87
88
+ private static NodeServicesOptions CreateNodeServicesOptions (
89
+ IServiceProvider serviceProvider , WebpackDevMiddlewareOptions options )
90
+ {
91
+ var nodeServicesOptions = new NodeServicesOptions ( serviceProvider )
92
+ {
93
+ WatchFileExtensions = new string [ ] { } // Don't watch anything
94
+ } ;
95
+
96
+ if ( ! string . IsNullOrEmpty ( options . ProjectPath ) )
97
+ {
98
+ nodeServicesOptions . ProjectPath = options . ProjectPath ;
99
+ }
100
+ if ( options . EnvironmentVariables != null )
101
+ {
102
+ nodeServicesOptions . EnvironmentVariables = options . EnvironmentVariables ;
103
+ }
104
+
105
+ return nodeServicesOptions ;
106
+ }
107
+
94
108
#pragma warning disable CS0649
95
109
class WebpackDevServerInfo
96
110
{
0 commit comments