create-react-library icon indicating copy to clipboard operation
create-react-library copied to clipboard

How to add Storybook?

Open sachinkotwal opened this issue 5 years ago • 13 comments

sachinkotwal avatar Jul 30 '19 21:07 sachinkotwal

+1

flearsnetwork avatar Aug 01 '19 20:08 flearsnetwork

+1

brightpixels avatar Aug 05 '19 11:08 brightpixels

+1

martinmcneela avatar Aug 17 '19 20:08 martinmcneela

+1

joey-lucky avatar Oct 24 '19 08:10 joey-lucky

I've spent a bit of the time on this one, but I wasn't been able to set up it properly. At some point probably next week, I will give it another go.

ummahusla avatar Oct 30 '19 08:10 ummahusla

+1

KindArt avatar Nov 25 '19 15:11 KindArt

As a workaround, I able to integrate storybook inside the example folder inside this library. This is straightforward as example project in this library is created using create-react-app

sachinkotwal avatar Nov 27 '19 14:11 sachinkotwal

+1

ericmasiello avatar Jan 07 '20 22:01 ericmasiello

@sachinkotwal could you share your example please?

brightpixels avatar Feb 28 '20 13:02 brightpixels

@brightpixels , I got this working by initializing storybook in example/ and installing react-scripts in example/. Starting storybook and importing from your library should work great after that.

cd example
npx -p @storybook/cli sb init
yarn add react-scripts
yarn storybook

EDIT: Looks like this might be a shortcut to that outcome, but haven't tested: npx -p @storybook/cli sb init --type react_scripts

AdventureBeard avatar Mar 10 '20 06:03 AdventureBeard

For anyone encountering this issue, even with the above solution I had an error Cannot find module ......./example/node_modules/react-scripts/config/webpack.config' I noticed the react-scripts version installed with this library is too old, I updated the package version to 3.4 at this time, and issue was solved

dasm30 avatar Mar 15 '20 20:03 dasm30

3.4

yup, this solved my issue

JFernandoGomez avatar Mar 29 '20 02:03 JFernandoGomez

I've added storybook in the root of create-react-library and it works fine. I don't need to use example folder anymore. I simply create the [file].stories.js inside each component and it works good. 👍🏽

saraahso avatar Mar 10 '21 20:03 saraahso