11 changed files with 388 additions and 256 deletions
@ -1,68 +1,72 @@ |
|||
# Directory Explanation |
|||
|
|||
The directory uses Monorepo management, and the project structure is as follows: |
|||
The repository uses Monorepo management, and the project structure is as follows: |
|||
|
|||
```bash |
|||
. |
|||
├── Dockerfile # Docker image build file |
|||
├── README.md # Project documentation |
|||
├── apps # Project applications directory |
|||
│ ├── backend-mock # Backend mock service application |
|||
│ ├── web-antd # Frontend application based on Ant Design Vue |
|||
│ ├── web-ele # Frontend application based on Element Plus |
|||
│ └── web-naive # Frontend application based on Naive UI |
|||
├── build-local-docker-image.sh # Script for building Docker images locally |
|||
│ ├── backend-mock # Backend mock service application |
|||
│ ├── web-antd # Frontend application based on Ant Design Vue |
|||
│ ├── web-antdv-next # Frontend application based on Ant Design Vue Next |
|||
│ ├── web-ele # Frontend application based on Element Plus |
|||
│ ├── web-naive # Frontend application based on Naive UI |
|||
│ └── web-tdesign # Frontend application based on TDesign |
|||
├── cspell.json # CSpell configuration file |
|||
├── docs # Project documentation directory |
|||
├── eslint.config.mjs # ESLint configuration file |
|||
├── lefthook.yml # Git hook configuration file |
|||
├── internal # Internal tools directory |
|||
│ ├── lint-configs # Code linting configurations |
|||
│ │ ├── commitlint-config # Commitlint configuration |
|||
│ │ ├── eslint-config # ESLint configuration |
|||
│ │ ├── prettier-config # Prettier configuration |
|||
│ │ └── stylelint-config # Stylelint configuration |
|||
│ ├── node-utils # Node.js tools |
|||
│ ├── tailwind-config # Tailwind configuration |
|||
│ ├── tsconfig # Common tsconfig settings |
|||
│ └── vite-config # Common Vite configuration |
|||
│ ├── lint-configs # Code linting configurations |
|||
│ │ ├── commitlint-config # Commitlint configuration |
|||
│ │ ├── eslint-config # ESLint configuration |
|||
│ │ ├── oxfmt-config # Oxfmt configuration |
|||
│ │ ├── oxlint-config # Oxlint configuration |
|||
│ │ └── stylelint-config # Stylelint configuration |
|||
│ ├── node-utils # Node.js tools |
|||
│ ├── tsconfig # Common tsconfig settings |
|||
│ └── vite-config # Common Vite configuration |
|||
├── oxfmt.config.ts # Oxfmt config entry |
|||
├── oxlint.config.ts # Oxlint configuration file |
|||
├── package.json # Project dependency configuration |
|||
├── packages # Project packages directory |
|||
│ ├── @core # Core package |
|||
│ │ ├── base # Base package |
|||
│ │ │ ├── design # Design related |
|||
│ │ │ ├── icons # Icons |
|||
│ │ │ ├── shared # Shared |
|||
│ │ │ └── typings # Type definitions |
|||
│ │ ├── composables # Composable APIs |
|||
│ │ ├── preferences # Preferences |
|||
│ │ └── ui-kit # UI component collection |
|||
│ │ ├── layout-ui # Layout UI |
|||
│ │ ├── menu-ui # Menu UI |
|||
│ │ ├── shadcn-ui # shadcn UI |
|||
│ │ └── tabs-ui # Tabs UI |
|||
│ ├── constants # Constants |
|||
│ ├── effects # Effects related packages |
|||
│ │ ├── access # Access control |
|||
│ │ ├── plugins # Plugins |
|||
│ │ ├── common-ui # Common UI |
|||
│ │ ├── hooks # Composable APIs |
|||
│ │ ├── layouts # Layouts |
|||
│ │ └── request # Request |
|||
│ ├── icons # Icons |
|||
│ ├── locales # Internationalization |
|||
│ ├── preferences # Preferences |
|||
│ ├── stores # State management |
|||
│ ├── styles # Styles |
|||
│ ├── types # Type definitions |
|||
│ └── utils # Utilities |
|||
│ ├── @core # Core package |
|||
│ │ ├── base # Base package |
|||
│ │ │ ├── design # Design related |
|||
│ │ │ ├── icons # Icons |
|||
│ │ │ ├── shared # Shared |
|||
│ │ │ └── typings # Type definitions |
|||
│ │ ├── composables # Composable APIs |
|||
│ │ ├── preferences # Preferences |
|||
│ │ └── ui-kit # UI component collection |
|||
│ │ ├── layout-ui # Layout UI |
|||
│ │ ├── menu-ui # Menu UI |
|||
│ │ ├── shadcn-ui # shadcn UI |
|||
│ │ └── tabs-ui # Tabs UI |
|||
│ ├── constants # Constants |
|||
│ ├── effects # Effects related packages |
|||
│ │ ├── access # Access control |
|||
│ │ ├── plugins # Large third-party dependency plugins |
|||
│ │ ├── common-ui # Common UI |
|||
│ │ ├── hooks # Composable APIs |
|||
│ │ ├── layouts # Layouts |
|||
│ │ └── request # Request |
|||
│ ├── icons # Icons |
|||
│ ├── locales # Internationalization |
|||
│ ├── preferences # Preferences |
|||
│ ├── stores # State management |
|||
│ ├── styles # Styles |
|||
│ ├── types # Type definitions |
|||
│ └── utils # Utilities |
|||
├── playground # Demo directory |
|||
├── pnpm-lock.yaml # pnpm lock file |
|||
├── pnpm-workspace.yaml # pnpm workspace configuration file |
|||
├── scripts # Scripts directory |
|||
│ ├── turbo-run # Turbo run script |
|||
│ └── vsh # VSH script |
|||
│ ├── deploy # Deployment-related scripts |
|||
│ ├── turbo-run # Turbo run script |
|||
│ └── vsh # VSH script |
|||
├── stylelint.config.mjs # Stylelint configuration file |
|||
├── turbo.json # Turbo configuration file |
|||
├── vben-admin.code-workspace # VS Code workspace configuration file |
|||
└── vitest.config.ts # Vite configuration file |
|||
└── vitest.config.ts # Vitest configuration file |
|||
``` |
|||
|
|||
@ -1,13 +1,38 @@ |
|||
# Tailwind CSS |
|||
|
|||
[Tailwind CSS](https://tailwindcss.com/) is a utility-first CSS framework for quickly building custom designs. |
|||
[Tailwind CSS](https://tailwindcss.com/) is a utility-first CSS framework for quickly building custom designs. The current project uses **Tailwind CSS v4**. |
|||
|
|||
## Configuration |
|||
|
|||
The project's configuration file is located in `internal/tailwind-config`, where you can modify the Tailwind CSS configuration. |
|||
The project no longer maintains Tailwind through `tailwind.config.*` files. Theme definitions and scan scope are now managed through CSS and the shared Vite configuration. |
|||
|
|||
::: tip Restrictions on using tailwindcss in packages |
|||
- Theme entry: `packages/@core/base/design/src/css/global.css` |
|||
- Vite integration: `internal/vite-config` |
|||
|
|||
Tailwind CSS compilation will only be enabled if there is a `tailwind.config.mjs` file present in the corresponding package. Otherwise, Tailwind CSS will not be enabled. If you have a pure SDK package that does not require Tailwind CSS, you do not need to create a `tailwind.config.mjs` file. |
|||
In `global.css`, you will see the Tailwind CSS v4 directives currently used by the project, such as: |
|||
|
|||
- `@source` |
|||
- `@custom-variant` |
|||
- `@theme` |
|||
- `@theme inline` |
|||
- `@utility` |
|||
|
|||
## How Packages Use Tailwind CSS |
|||
|
|||
The project does not decide whether Tailwind CSS is enabled based on whether a package contains `tailwind.config.mjs`. |
|||
|
|||
Apps and packages share `@vben/vite-config`, which integrates `@tailwindcss/vite`. The Tailwind scan scope is managed centrally in `packages/@core/base/design/src/css/global.css`. |
|||
|
|||
::: tip Notes on using Tailwind CSS in packages |
|||
|
|||
If you are building a pure SDK package and do not need Tailwind CSS, you do not need to add any legacy `tailwind.config.*` file. |
|||
|
|||
::: |
|||
|
|||
## `@apply` in Vue SFCs |
|||
|
|||
The project applies a shared handling layer for `@apply` inside Vue single-file components. The related logic is located at: |
|||
|
|||
- `internal/vite-config/src/plugins/tailwind-reference.ts` |
|||
|
|||
When component styles use `@apply`, the required `@reference` is injected automatically in most cases. |
|||
|
|||
@ -1,17 +1,38 @@ |
|||
# Tailwind CSS |
|||
|
|||
[Tailwind CSS](https://tailwindcss.com/) 是一个实用性优先的CSS框架,用于快速构建自定义设计。 |
|||
[Tailwind CSS](https://tailwindcss.com/) 是一个实用性优先的 CSS 框架,用于快速构建自定义设计。当前项目使用的是 **Tailwind CSS v4**。 |
|||
|
|||
## 配置 |
|||
|
|||
项目的配置文件位于 `internal/tailwind-config` 下,你可以在这里修改 Tailwind CSS 的配置。 |
|||
项目当前不再通过 `tailwind.config.*` 文件维护 Tailwind 配置,主题与扫描范围都统一放在 CSS 与共享 Vite 配置中。 |
|||
|
|||
::: tip 包使用 tailwindcss 的限制 |
|||
- 主题入口:`packages/@core/base/design/src/css/global.css` |
|||
- Vite 集成:`internal/vite-config` |
|||
|
|||
当前只有对应的包下面存在 `tailwind.config.mjs` 文件才会启用 tailwindcss 的编译,否则不会启用 tailwindcss。如果你是纯粹的 SDK 包,不需要使用 tailwindcss,可以不用创建 `tailwind.config.mjs` 文件。 |
|||
在 `global.css` 中你会看到当前项目使用的 Tailwind CSS v4 指令,例如: |
|||
|
|||
- `@source` |
|||
- `@custom-variant` |
|||
- `@theme` |
|||
- `@theme inline` |
|||
- `@utility` |
|||
|
|||
## 包使用 Tailwind CSS 的方式 |
|||
|
|||
当前项目不会根据某个包下是否存在 `tailwind.config.mjs` 来决定是否启用 Tailwind CSS。 |
|||
|
|||
应用和包统一复用 `@vben/vite-config`,并由该配置接入 `@tailwindcss/vite`。Tailwind 的扫描范围则统一在 `packages/@core/base/design/src/css/global.css` 中维护。 |
|||
|
|||
::: tip 包使用 Tailwind CSS 的说明 |
|||
|
|||
如果你是纯粹的 SDK 包,不需要使用 Tailwind CSS,则无需额外增加旧版 `tailwind.config.*` 文件。 |
|||
|
|||
::: |
|||
|
|||
## 提示 |
|||
## Vue SFC 中的 `@apply` |
|||
|
|||
项目对 Vue 单文件组件中的 `@apply` 做了统一处理,相关逻辑位于: |
|||
|
|||
- `internal/vite-config/src/plugins/tailwind-reference.ts` |
|||
|
|||
现`tailwindcss`已至v4.x版本,使用方法与`tailwindcss: ^3.4.17`有差异,v4.0无法与v3.x版本兼容,在开发前请确认`package.json`中的`tailwindcss`版本。 |
|||
当组件样式中使用 `@apply` 时,会自动注入对应的 `@reference`,一般不需要手动补充。 |
|||
|
|||
Loading…
Reference in new issue