DEV Community


Discussion on: Monorepos: Lerna, TypeScript, CRA and Storybook combined

anil1712 profile image
Anil Kumar Pandey • Edited

Hi @shnyder, first of all very very thanks for writing this, it is very clean, understandable and helpful.

I ran the script through github and it works perfectly fine, but now I want build my component using the React Material UI (, so what is the best way to add this dependency?

Should I directly run the yarn add @material-ui/core in the root of the project? How it will add the dependency to storybook and cra app?

shnydercom profile image
Jonathan Schneider (shnyder) Author

Both, you can also use yarn lerna add @material-ui/core --scope=@my-org/my-monorepo-ui-lib at the root. In my experience it works well for single packages, if you want to add many it often doesn't.

Then you can import material ui Components in your own component inside the UI lib, e.g.

import {Button} from '@material-ui/core';

and run yarn story for adjusting it in storybook. Because it's a sub-dependency of the UI lib package, you'll have it included when you run CRA with yarn start as well.

anil1712 profile image
Anil Kumar Pandey

Very Very thank you for the quick reply, I tried it and it is working fine.

Can you please share how do I create the builds. Dev (minify with js map files) and Prod (complete minify) ?

Please suggest me something to achieve this.