-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
start-storybook: open browser tab on first compilation #4149
Conversation
lib/core/src/server/build-dev.js
Outdated
@@ -153,6 +155,8 @@ Would you like to run Storybook on port ${port} instead?`, | |||
logger.info(`Storybook started on => ${chalk.cyan(address)}\n`); | |||
if (program.smokeTest) { | |||
process.exit(stats.toJson().warnings.length ? 1 : 0); | |||
} else { | |||
opn(address); |
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.
A lot of users are using SB dev mode in CI. I would say that this should be opt-out
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.
Done
Codecov Report
@@ Coverage Diff @@
## master #4149 +/- ##
==========================================
- Coverage 40.46% 40.45% -0.02%
==========================================
Files 491 491
Lines 5839 5841 +2
Branches 792 792
==========================================
Hits 2363 2363
- Misses 3088 3090 +2
Partials 388 388
Continue to review full report at Codecov.
|
@@ -88,6 +88,10 @@ Storybook now uses Babel 7. There's a couple of cases when it can break with you | |||
``` | |||
* If you're using Babel 6, make sure that you have direct dependencies on `babel-core@6` and `babel-loader@7`. | |||
|
|||
### start-storybook opens browser automatically | |||
|
|||
If you're using `start-storybook` on CI, you may need to opt out of this using the new `--ci` flag. |
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.
Maybe check for process.env.CI
too? It's set by most CI systems
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 actually think that ci
is too limiting
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.
yep. it would be much better to have something like BROWSER=none start-storybook
. This is the same, that is used by cra or docusaurus.
@@ -53,7 +53,7 @@ | |||
"postpublish": "yarn --cwd lib/cli test -o", | |||
"publish:alpha": "npm run publish -- --npm-tag=alpha", | |||
"repo-dirty-check": "node ./scripts/repo-dirty-check", | |||
"start": "npm --prefix examples/official-storybook run storybook", | |||
"start": "yarn --cwd examples/official-storybook storybook", |
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.
does this require people to have yarn installed?
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.
not really, I believe this is only applicable to the storybook project itself
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.
does this require people to have yarn installed?
You need it anyway when you contribute to storybook, see CONTRIBUTING.md
Devs restarting locally their already opened storybook will have to provide --ci, which might not be the most meaningful parameter name. WDYT ? (somethink containing 'skip' or 'browser' could be easier to understand) |
I don't think that opening more than one tab is so much a problem. CRA tries to solve it on OS X this using appleScript. The problem is, it opens Google Chrome regardless of which browser user has as default. I don't think we should do it unless Google acquires us. |
I have been using react-scripts and I can tell that in windows/linux, it opens a new tab for each start command issued, which can be disturbing. |
I think it's worth it Yes I've had like 10 tabs open with the same dev setup once.. Thats' not great, but overall I think the experience is better then not having anything opened at all. Thanks @Hypnosphi 👍👍👍 |
I'm on alpha.23 and it opens a new tab every time i restart storybook, regardless if I already have it open. I've used react-dev-utils/openBrowser.js before, and it uses opn like this pull-request adds, but also check with AppleScript if there is a tab already open. |
|
@einarlove question: I mean -I- do restart it all the time, so i know there are use cases. But mine is I maintain storybook's code... I'd like to know what's yours. Perhaps you don't need to restart storybook all the time? If you have multiple storybooks you can run them on a different port If storybook breaks down somehow and the only fix is a restart, let's fix it? |
I always have it running and switching between branches might break it after a while. Suddenly there's a conflict in package.json and etc, and a restart might be required to get it up to speed again. That's at least my experience. Maybe I'm overdoing it? |
Hmm, no that sounds like it could be quite common. I guess our CLI could be smarter about broken code and recovering afterwards. |
How to test
Run
yarn start