ts-react-tailwind-library-starter
v0.0.2
Published
A starter template to create a component library with React, TailwindCSS, vitejs, Storybook and TypeScript
Downloads
2
Readme
React Component Library Starter
A starter template to create a component library with React, TailwindCSS, vitejs, Storybook and TypeScript
Getting Started
Install dependencies and start developing components
yarn install # install depedencies
yarn storybook # run storybook
yarn build # build the library
yarn publish # publish the library
You can also use the built-in site to test or document your components
yarn dev:site # site dev mode
yarn build:site # build site
yarn preview:site #priview built site
Using the library
Install peer dependencies: React & ReactDOM, Tailwind CSS and Headless UI
Install the component library
yarn add ts-react-tailwind-library-starter
In your project root, import the library CSS file
import 'ts-react-tailwind-library-starter/dist/style.css';
Step By Step Guide
Create a new react-ts vite project
yarn create vite --template react-ts
Install Tailwind CSS and PostCSS, and initialize
tailwind.config.js
yarn add -D tailwindcss postcss autoprefixer # install dependencies npx tailwindcss init # create `tailwind.config.js`
Add
postcss.config.js
to project rootmodule.exports = { plugins: { tailwindcss: {}, autoprefixer: {}, }, };
Turn on Vite Library Mode
import { defineConfig } from 'vite'; import { resolve } from 'path'; import react from '@vitejs/plugin-react'; // https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], build: { lib: { entry: resolve(__dirname, 'src', 'index.ts'), formats: ['es', 'cjs'], fileName: (ext) => `index.${ext}.js`, }, rollupOptions: { // make sure to externalize deps that shouldn't be bundled // into your library external: ['react', 'react-dom', '@headlessui/react'], }, target: 'esnext', sourcemap: true, }, });
Install Storybook
npx sb init --builder storybook-builder-vite
TODO
FAQ
- TODO