Skip to content

Commit

Permalink
Scripts: coerce live reload port to integer (#29196)
Browse files Browse the repository at this point in the history
* Scripts: coerce live reload port to integer

* Scripts: simplify by removing defaultPort argument
  • Loading branch information
emilio-martinez committed Feb 23, 2021
1 parent 2a55b96 commit e9ab152
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/scripts/config/webpack.config.js
Expand Up @@ -76,6 +76,12 @@ const getJsonpFunctionIdentifier = () => {
);
};

const getLiveReloadPort = ( inputPort ) => {
const parsedPort = parseInt( inputPort, 10 );

return Number.isInteger( parsedPort ) ? parsedPort : 35729;
};

const config = {
mode,
entry: {
Expand Down Expand Up @@ -221,7 +227,7 @@ const config = {
// works when running watch mode.
! isProduction &&
new LiveReloadPlugin( {
port: process.env.WP_LIVE_RELOAD_PORT || 35729,
port: getLiveReloadPort( process.env.WP_LIVE_RELOAD_PORT ),
} ),
// WP_NO_EXTERNALS global variable controls whether scripts' assets get
// generated, and the default externals set.
Expand Down

0 comments on commit e9ab152

Please sign in to comment.