This is the tutorial about how to make,publish npm package with Vite - React, TypeScript
$ npm create vite@latest
(optional)
$ npm install -D tailwindcss postcss autoprefixer
my setting
✔ Select a framework: › React ✔ Select a variant: › TypeScript + SWC
After you installed npm package, you will see initial project screen.
Optional
/** @type {import('tailwindcss').Config} */
export default {
@tailwind base;
@tailwind components;
@tailwind utilities;
you also need to add
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import dts from "vite-plugin-dts";
import path from "path";
export default defineConfig({
build: {
lib: {
entry: path.resolve(__dirname, "index.ts"),
name: "ViteButton",
fileName: (format) => `index.${format}.js`,
},
rollupOptions: {
external: ["react", "react-dom"],
output: {
globals: {
react: "React",
"react-dom": "ReactDOM",
},
},
},
sourcemap: true,
emptyOutDir: true,
},
plugins: [react(), dts()],
});
Basically followed this tutorial!
Make react hook component using storybook