Skip to content

Commit bbf58fe

Browse files
adamstankiewiczmuselesscreator
authored andcommitted
fix: ensure .env.development PORT works (#423)
1 parent 012c4ee commit bbf58fe

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/scripts/serve.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ if (isDirectoryEmpty(buildPath)) {
4040
console.log(chalk.bold.red(`ERROR: No build found. Please run ${formattedBuildCmd} first.`));
4141
} else {
4242
let configuredPort;
43-
let envConfig;
4443

4544
try {
46-
envConfig = require(path.join(process.cwd(), 'env.config.js'));
47-
configuredPort = envConfig?.PORT || process.env.PORT;
45+
configuredPort = require(path.join(process.cwd(), 'env.config.js'))?.PORT;
4846
} catch (error) {
49-
// pass, consuming applications may not have an `env.config.js` file. This is OK.
47+
// Pass. Consuming applications may not have an `env.config.js` file. This is OK.
48+
}
49+
50+
if (!configuredPort) {
51+
configuredPort = process.env.PORT;
5052
}
5153

5254
// No `PORT` found in `env.config.js` and/or `.env.development|private`, so output a warning.

0 commit comments

Comments
 (0)