-
-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggest a new port for development server if default port is in use. #196
Conversation
Oops !! committed My bad :( |
src/lib/webpack/run-webpack.js
Outdated
process.stdout.write(chalk.green('Compiled successfully!!\n\n')); | ||
process.stdout.write('You can view the application in the browser.\n\n'); | ||
process.stdout.write(chalk.green('\nCompiled successfully!!\n\n')); | ||
if (parseInt(port, 10) !== parseInt(config.devServer.port, 10)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Showing this message only when it is not using default port. So, it will be easy for the users to understand what port it has been changed to !!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should still respect the hierarchy of user-defined ports:
process.env.PORT || config.devServer.port || 8080
This fixes #179 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot I could push to PRs 😅
I added changes so that we only showed the "using different port" message if user actually defined a port. Since 8080
is a default (aka, not specified) I don't think we have to warn/alert users about the change.
Also, moved parseInt
call to process.env.PORT
only because it's the only item that is passed in as a string.
Looks good, thanks!!
This PR opens dev server in a new port if the default port is already in use.
Here's how it looks: