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

feat(tailwindcss): support config CHECK_TIMEOUT #12920

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion docs/docs/docs/max/tailwindcss.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ toc: content

使用微生成器一键开启 Tailwind CSS 插件


Max 项目

```bash
Expand All @@ -34,3 +33,12 @@ info - Write tailwind.css
```

至此就可以在项目中使用 Tailwind CSS 的样式;项目根目录的 `tailwind.config.js` 和 `tailwind.css` 根据需要修改配置。

## Env

在项目根目录添加 `.env` 文件,添加 `CHECK_TIMEOUT` 变量,用于设置 Tailwind CSS 插件的检查间隔时间。

```bash
# Default: 5
CHECK_TIMEOUT=10
```
8 changes: 5 additions & 3 deletions packages/plugins/src/tailwindcss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { IApi } from 'umi';
import { crossSpawn, winPath } from 'umi/plugin-utils';

const CHECK_INTERVAL = 300;
const CHECK_TIMEOUT_UNIT_SECOND = 5;
const CHECK_TIMEOUT = process.env.CHECK_TIMEOUT
? parseInt(process.env.CHECK_TIMEOUT, 10)
: 5;

export default (api: IApi) => {
api.describe({
Expand Down Expand Up @@ -70,11 +72,11 @@ export default (api: IApi) => {
if (!existsSync(generatedPath)) {
clearInterval(timer);
api.logger.error(
`tailwindcss generate failed after ${CHECK_TIMEOUT_UNIT_SECOND} seconds, please check your tailwind.css and tailwind.config.js`,
`tailwindcss generate failed after ${CHECK_TIMEOUT} seconds, please check your tailwind.css and tailwind.config.js`,
);
process.exit(1);
}
}, CHECK_TIMEOUT_UNIT_SECOND * 1000);
}, CHECK_TIMEOUT * 1000);
}
});
});
Expand Down