mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-25 11:07:29 +00:00
Allow explicit configuration of port number for webpack dev middleware server. Fixes #223.
This commit is contained in:
@@ -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