question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple Storybooks configs (multi framework) in same repo not working

See original GitHub issue

This is a weird one. I’ve figured out a workaround, but this is different behavior than SB4.

Describe the bug I have @storybook/html, @storybook/react, and @storybook/vue installed and they use their own config files that I point to.

To Reproduce

Here are my npm scripts

"storybook:html": "cross-env NODE_PATH=styles:components start-storybook -s ./vendor -p 9005 -c .storybook/html",
"storybook:vue": "cross-env NODE_PATH=styles:components start-storybook -p 9006 -c .storybook/vue",
    "storybook:react": "cross-env NODE_PATH=styles:components start-storybook -p 9007 -c .storybook/react",

When I run storybook:react, in termial, I get this:

> cross-env NODE_PATH=styles:components start-storybook -p 9007 -c .storybook/react

info @storybook/vue v5.0.6

Expected behavior I would expect @storybook/react to firing things up. I tried removing @storybook/vue and then when I ran npm run storybook:react, it fires up with @storybook/html!

My hunch is, start-storybook’s behavior has changed. If I run npx start-storybook or npx start-storybook -c .storybook/react, it runs @storybook/vue still, despite me pointing to a React config file.

I would expect start-storybook to simply find the config and infer the Storybook type from the imports.

Maybe multi-framework support wasn’t in mind in this fashion (I know it is on the road map except as a single Storybook), but they share style and image assets. It worked out fine in SB4.

Here’s my workaround. I just point straight the desired bin:

"storybook:html": "cross-env NODE_PATH=styles:components node_modules/@storybook/html/bin/index.js -s ./vendor -p 9005 -c .storybook/html",
"storybook:vue": "cross-env NODE_PATH=styles:components node_modules/@storybook/vue/bin/index.js -p 9006 -c .storybook/vue",
"storybook:react": "cross-env NODE_PATH=styles:components node_modules/@storybook/react/bin/index.js -p 9007 -c .storybook/react",

System:

  • OS: macOS Mojave 10.14.3
  • Device: Macbook Pro 2018
  • Browser: Chrome
  • Framework: React
  • Version: 5.0.6

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
lubomir-chatoryiskyicommented, Oct 1, 2019

@tarikhamilton I’ve faced the same problem and tried to use your approach. I ran npx -p @storybook/cli sb init, my env was initialised for vue.js, after I added configs for React and HTML but @storybook/vue was used. The same as yours. After I installed @storybook/cli as a dependency but didn’t initialise it. And added

"storybook:js": "node_modules/@storybook/html/bin/index.js -s ./public -p 9005 -c config/js",
"storybook:vue": "node_modules/@storybook/vue/bin/index.js -s ./public -p 9006 -c config/vue"

to my package.json file It takes the appropriate config file and works! So it can be a trick for those who want to use storybook for multiple framework

Hope it helps.

2reactions
DmitryEfimenkocommented, Oct 22, 2019

I’d like to see this feature working

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to combine multiple Storybooks into one - Medium
The ideal developer experience is to interact with all Storybooks together at once. But this requires every project to have the same tech...
Read more >
Storybook Composition
Storybook is a frontend workshop for building UI components and pages in isolation. Thousands of teams use it for UI development, testing, and...
Read more >
Support Multiple Frameworks in a Monorepo - CSS-Tricks
We're going to make a Yarn workspaces-based monorepo that supports multiple frameworks, including React, Vue, Svelte, and Angular.
Read more >
Storybook Composition - Chromatic
Combine multiple Storybooks into one. ... Combine multiple Storybooks into one; Browse components from different frameworks side-by-side ...
Read more >
Configure syncing from multiple repositories | Anthos Config ...
Before you begin. Create, or make sure you have access to, an unstructured Git repository that can contain the configs that Config Sync...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found