-
-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
[WIP] Use a different port if 3000 is used #100
Conversation
@@ -16,6 +16,9 @@ var WebpackDevServer = require('webpack-dev-server'); | |||
var config = require('../config/webpack.config.dev'); | |||
var execSync = require('child_process').execSync; | |||
var opn = require('opn'); | |||
var portfinder = require('portfinder'); | |||
|
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 think you can have a var PORT = 3000
here and let the callback of portfinder.getPort
re-assign this variable. Then the webpack done
callback can just do console.log('The app is running at http://localhost:' + PORT + '/');
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.
👍 Keyan to the rescue.
Updated—now it's working (I think) but UX is still up to debate. I like this way of doing it as the user doesn't have to worry about anything—it'll work and show the available port. |
What if you didn't intend to start another secret and just forgot one is already running in a different terminal tab? Ideally we wouldn't want to spend time initializing just to open |
Good point. I'm gonna close this in favor of #101, that's looks like a better solution! |
Use ts-jest instead of custom solution for transforming ts files
Work in progress!
Fixes #85.
The idea is to detect if port 3000 is used by something else and if so, use a different port.
portfinder
takes in abasePort
and returns that if it's available. If not, it'll use the next available port. This was a good solution because we can use 3000 as thebasePort
.The problem is that while I can pass the
port
to the function that opens the browser, I can't pass it to the function that logsThe app is running at http://localhost:3000/
.Assuming this UX is fine (@gaearon wanted a prompt, but I feel like this is less intrusive), how can I let the logging functions know about the new port?
Thanks!