Install Tailwind CSS with Vite and Vue3

8 min read

初始化项目

npm create vite@latest my-project -- --template vue
cd my-project

安装依赖

pnpm add -D tailwindcss postcss autoprefixer
npx tailwindcss init -p

初始化配置

// tailwind.config.cjs

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./index.html",
    "./src/**/*.{vue,js,ts,jsx,tsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

模块分层配置

#style.css

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