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