Giter Site home page Giter Site logo

anakornk / ts-react-tailwind-library-starter Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 207 KB

A starter template to create a component library with React, TailwindCSS, vitejs, Storybook and TypeScript

HTML 2.47% CSS 16.02% TypeScript 76.36% JavaScript 5.15%

ts-react-tailwind-library-starter's Introduction

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

  1. Install peer dependencies: React & ReactDOM, Tailwind CSS and Headless UI

  2. Install the component library

    yarn add ts-react-tailwind-library-starter
  3. In your project root, import the library CSS file

    import 'ts-react-tailwind-library-starter/dist/style.css';

Step By Step Guide

  1. Create a new react-ts vite project

    yarn create vite --template react-ts
  2. 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`
  3. Add postcss.config.js to project root

    module.exports = {
      plugins: {
        tailwindcss: {},
        autoprefixer: {},
      },
    };
  4. 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,
      },
    });
  5. Install Storybook

    npx sb init --builder storybook-builder-vite
  6. TODO

FAQ

  • TODO

ts-react-tailwind-library-starter's People

Contributors

anakornk avatar

Stargazers

Bruce Wang avatar Roman avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.