PauloLuan / nx-react-native-example

Monorepo for my React Native apps.
2 stars 0 forks source link

Could we get styled components working or tailwind in the shared ui library? #1

Open algoflows opened 2 years ago

algoflows commented 2 years ago

I am struggling to get styled components working across the different applications and or tailwind working. What about storybook, would that be possible?

Have you tried anything like this?

PauloLuan commented 2 years ago

hey @algoflows I have another example in which I've used a lerna monorepo with storybook and a shared-ui library with styled components.

Here is the example.

Feel free to copy and use it as a boilerplate base for your app (you can check how I configured that in the shared ui package.json) it is just a simple compile script using babel (another important thing that I forget to put there, is that you have to add the styled component lib as a peer-dependency).

Meanwhile, in the application you're gonna consume your shared-ui, you should add it as a dependency (you can check it here on line 11)

Another important thing, is that, once you have did it, you have to go in you root folder and type the command lerna bootstrap in order to make your shared library a symbolic link to your node_modules folder, this is where the magic happen, because for each modification you're gonna do in your shared lib, it'll reflect on your node_modules folder and also to the apps that consume this lib.

Another important fact, is that for each modification in your shared lib you have to compile it, because the folder that is gonna be exposed to your other packages will be the dist folder (unless you change this config on your package, on the line 14 for example...).

I never configured it with tailwind, but I'm almost sure that would be almost the same as this example.