Skip to content

Commit

Permalink
feat(tailwindcss): support config CHECK_TIMEOUT, Close #12914
Browse files Browse the repository at this point in the history
  • Loading branch information
sorrycc committed Feb 14, 2025
1 parent 95872bd commit fb61930
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
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

0 comments on commit fb61930

Please sign in to comment.