mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Fix UseWebpackDevMiddleware with no options
This commit is contained in:
@@ -18,11 +18,12 @@ namespace Microsoft.AspNet.Builder
|
|||||||
|
|
||||||
public static void UseWebpackDevMiddleware(this IApplicationBuilder appBuilder, WebpackDevMiddlewareOptions options = null) {
|
public static void UseWebpackDevMiddleware(this IApplicationBuilder appBuilder, WebpackDevMiddlewareOptions options = null) {
|
||||||
// Validate options
|
// Validate options
|
||||||
if (options != null) {
|
if (options == null) {
|
||||||
|
options = new WebpackDevMiddlewareOptions();
|
||||||
|
}
|
||||||
if (options.ReactHotModuleReplacement && !options.HotModuleReplacement) {
|
if (options.ReactHotModuleReplacement && !options.HotModuleReplacement) {
|
||||||
throw new ArgumentException("To enable ReactHotModuleReplacement, you must also enable HotModuleReplacement.");
|
throw new ArgumentException("To enable ReactHotModuleReplacement, you must also enable HotModuleReplacement.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Unlike other consumers of NodeServices, WebpackDevMiddleware dosen't share Node instances, nor does it
|
// Unlike other consumers of NodeServices, WebpackDevMiddleware dosen't share Node instances, nor does it
|
||||||
// use your DI configuration. It's important for WebpackDevMiddleware to have its own private Node instance
|
// use your DI configuration. It's important for WebpackDevMiddleware to have its own private Node instance
|
||||||
@@ -43,7 +44,7 @@ namespace Microsoft.AspNet.Builder
|
|||||||
// Tell Node to start the server hosting webpack-dev-middleware
|
// Tell Node to start the server hosting webpack-dev-middleware
|
||||||
var devServerOptions = new {
|
var devServerOptions = new {
|
||||||
webpackConfigPath = Path.Combine(appEnv.ApplicationBasePath, options.ConfigFile ?? DefaultConfigFile),
|
webpackConfigPath = Path.Combine(appEnv.ApplicationBasePath, options.ConfigFile ?? DefaultConfigFile),
|
||||||
suppliedOptions = options ?? new WebpackDevMiddlewareOptions()
|
suppliedOptions = options
|
||||||
};
|
};
|
||||||
var devServerInfo = nodeServices.InvokeExport<WebpackDevServerInfo>(nodeScript.FileName, "createWebpackDevServer", JsonConvert.SerializeObject(devServerOptions)).Result;
|
var devServerInfo = nodeServices.InvokeExport<WebpackDevServerInfo>(nodeScript.FileName, "createWebpackDevServer", JsonConvert.SerializeObject(devServerOptions)).Result;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user