Is it possible to implement this feature? I find it very handy when starting up the dev server.
Looking through create-react-app scripts/start.js
, it seems that they use an external openBrowser
package like so:
const openBrowser = require('react-dev-utils/openBrowser')
// then open the dev server url with the package
openBrowser(urls.localUrlForBrowser);
If it's a trivial change, I'd love to take a stab at it!
Try gatsby develop --open
Usage: develop [options]
Start development server. Watches files and rebuilds and hot reloads if something changes
Options:
-h, --help output usage information
-H, --host <url> Set host. Defaults to localhost
-p, --port <port> Set port. Defaults to 8000
-o, --open Open the site in your browser for you.
Ahh! Should've looked that up before posting this. Sorry about that and thanks for the quick response!
Opening the site by default is an interesting default. @prayasht do you really like this? We could change the default. I haven't used CRA much or other systems which open pages by default. Is there other tools that do this?
The only downside I see is it grabs the focus of your OS which can be annoying.
I don't like th default of CRA (you can change it with config though), it's quite annoying and you end up with a lot of tabs. As long as it's possible to configure, I think either default is fine.
@oscar-b On my machine (macOS + Chrome), if an instance is already open in a tab, it simply refreshes it. I've never had it open new instances every time I run the dev server.
Honestly, I like it and I just changed my npm script to gatsby develop --open
so that's easy enough for me. Not sure about others though!
Let's leave this open for a while to see if anyone else has strong feelings about it
Just chiming in as a create-react-app user to say that I really like the app to open as a default; gatsby develop --open
works fine for me as well, though.
--open
should not be the default.
I share the same dislike for Gatsby taking control of my OS windows, even just to launch a browser. I changed the default behavior in CRA the moment I installed it.
This can be easily scripted. Most sites already wrap gatsby build
as npm run build
— my two cents? --open
can be just as easily included there, in your package.json
, on a project-by-project basis.
Going to chime in and say that --open
should _not_ be a default.
I too agree, -o
shouldn't be default.
Leaving it not as the default :-)
Most helpful comment
Try
gatsby develop --open