Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

初始化 Vue 项目 #6

Open
zhnoah opened this issue Sep 6, 2024 · 0 comments
Open

初始化 Vue 项目 #6

zhnoah opened this issue Sep 6, 2024 · 0 comments

Comments

@zhnoah
Copy link
Owner

zhnoah commented Sep 6, 2024

初始化 Vue 项目

创建项目

  1. 利用 create-vue(vite) 创建项目
npm create vue@latest
  1. 更改 npm 源

创建 .npmrc 更改 npm 源加速包的安装

  1. 安装依赖
yarn install
  1. 启动项目
yarn dev

添加 TailwindCSS

  1. 添加依赖
yarn add -D tailwindcss autoprefixer
  1. 初始化
npx tailwindcss init -p

Note: 如果使用 shadcn-vue 则后续步骤可省略

  1. 更新配置

file: tailwind.config.js

content: [
    "./index.html",
    "./src/**/*.{vue,js,ts,jsx,tsx}",
],
  1. 添加引用

file: assets/index.css

@tailwind base;
@tailwind components;
@tailwind utilities;

添加 shadcn-vue

  1. 初始化
npx shadcn-vue@latest init

Note: 如果出现 node:internal/modules/esm/resolve:207 错误,则执行以下命令

npm i shadcn-vue@latest --no-package-lock
  1. 添加组件
npx shadcn-vue@latest add
  1. 引用组件
import { Button } from '@/components/ui/button'

优化开发环境

  1. 推荐 vscode 安装 tailwindcss 插件

file: .vscode/extensions.json

bradlc.vscode-tailwindcss
  1. 自动 tailwindcss class 排序

安装依赖

yarn add -D prettier-plugin-tailwindcss

添加配置

file: .prettierrc.json

"plugins": ["prettier-plugin-tailwindcss"]

Note: 如果无效注意检查系统级的格式化设置

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant