I want to build a component library on top of tailwindcss. Therefore I want to encapsulate my components with bit.dev. Is this possible, or are these two competitive approaches?
It is possible. I managed to do it as follows. (Using latest v15 - Bit Harmony)
Before you get started with your project, set up a collection through your Bit profile: https://bit.dev/~create-collection
npm i -g @teambit/bvmbvm installbit loginbit init --harmonyworkspace.jsonc in the root folder of your project: {
"defaultScope": "your-profile.your-collection"
}
Everything else in that file can (should?) stay the same.
tailwind-config/index.jsbit add tailwind-confignpm install)bit tag --all a.k.a. commit (as we know from git)bit export a.k.a. pushThe component should now appear in your collection and you can also reuse the Tailwind's config file across various projects using any package manager e.g. npm install @your-profile/your-collection.tailwind-config
And lastly, add this to your tailwind.config.js file:
module.exports = require('./node_modules/@your-profile/your-collection.tailwind-config')
I would personally say, this is a great way to have a consistent and functional design system.
For more information about Bit's inner workings, have a look at the documentation: https://harmony-docs.bit.dev/
UPDATE: The best way to initialise a freshly pulled repository (that includes .bitmap & workspace.jsonc) is using bit import and then npm install
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With