Skip to content

新建一个 react 项目

bash
# pnpm,  --template [react-ts / react-swc / react-swc-ts]
yarn create vite my-react-app --template react

安装 UI 库

shadcn/ui

bash
pnpm install -D tailwindcss postcss autoprefixer

npx tailwindcss init -p

# Edit tsconfig.json file

# import path
pnpm i -D @types/node

# Edit vite.config.ts(js)

npx shadcn-ui@latest init

# adding components to your project
npx shadcn-ui@latest add button
json
{
  "compilerOptions": {
    // ...
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    }
    // ...
  }
}
json
{
  "compilerOptions": {
    // ...
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    }
    // ...
  }
}
js
import path from "path";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
});

安装必备库

bash
# 避免 mutation 问题
pnpm install use-immer
2025( )
今日 8.33%
本周 42.86%
本月 48.39%
本年 4.11%
Powered by Snowinlu | Copyright © 2024- | MIT License