mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Allow explicit configuration of port number for webpack dev middleware server. Fixes #223.
This commit is contained in:
@@ -3,6 +3,7 @@ namespace Microsoft.AspNetCore.SpaServices.Webpack
|
||||
public class WebpackDevMiddlewareOptions
|
||||
{
|
||||
public bool HotModuleReplacement { get; set; }
|
||||
public int HotModuleReplacementServerPort { get; set; }
|
||||
public bool ReactHotModuleReplacement { get; set; }
|
||||
public string ConfigFile { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "aspnet-webpack",
|
||||
"version": "1.0.7",
|
||||
"version": "1.0.8",
|
||||
"description": "Helpers for using Webpack in ASP.NET Core projects. Works in conjunction with the Microsoft.AspNetCore.SpaServices NuGet package.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -16,6 +16,7 @@ interface CreateDevServerOptions {
|
||||
// These are the options configured in C# and then JSON-serialized, hence the C#-style naming
|
||||
interface DevServerOptions {
|
||||
HotModuleReplacement: boolean;
|
||||
HotModuleReplacementServerPort: number;
|
||||
ReactHotModuleReplacement: boolean;
|
||||
}
|
||||
|
||||
@@ -35,9 +36,11 @@ export function createWebpackDevServer(callback: CreateDevServerCallback, option
|
||||
return;
|
||||
}
|
||||
|
||||
// The default value, 0, means 'choose randomly'
|
||||
const suggestedHMRPortOrZero = options.suppliedOptions.HotModuleReplacementServerPort;
|
||||
|
||||
const app = connect();
|
||||
const defaultPort = 0; // 0 means 'choose randomly'. Could allow an explicit value to be supplied instead.
|
||||
const listener = app.listen(defaultPort, () => {
|
||||
const listener = app.listen(suggestedHMRPortOrZero, () => {
|
||||
// Build the final Webpack config based on supplied options
|
||||
if (enableHotModuleReplacement) {
|
||||
// TODO: Stop assuming there's an entry point called 'main'
|
||||
|
||||
Reference in New Issue
Block a user