Skip to content

Commit 9c3194d

Browse files
authored
feat(tailwindcss): support config CHECK_TIMEOUT, Close #12914 (#12920)
1 parent c63773f commit 9c3194d

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

docs/docs/docs/max/tailwindcss.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ toc: content
1010

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

13-
1413
Max 项目
1514

1615
```bash
@@ -34,3 +33,12 @@ info - Write tailwind.css
3433
```
3534

3635
至此就可以在项目中使用 Tailwind CSS 的样式;项目根目录的 `tailwind.config.js``tailwind.css` 根据需要修改配置。
36+
37+
## Env
38+
39+
在项目根目录添加 `.env` 文件,添加 `CHECK_TIMEOUT` 变量,用于设置 Tailwind CSS 插件的检查间隔时间。
40+
41+
```bash
42+
# Default: 5
43+
CHECK_TIMEOUT=10
44+
```

packages/plugins/src/tailwindcss.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { IApi } from 'umi';
44
import { crossSpawn, winPath } from 'umi/plugin-utils';
55

66
const CHECK_INTERVAL = 300;
7-
const CHECK_TIMEOUT_UNIT_SECOND = 5;
7+
const CHECK_TIMEOUT = process.env.CHECK_TIMEOUT
8+
? parseInt(process.env.CHECK_TIMEOUT, 10)
9+
: 5;
810

911
export default (api: IApi) => {
1012
api.describe({
@@ -70,11 +72,11 @@ export default (api: IApi) => {
7072
if (!existsSync(generatedPath)) {
7173
clearInterval(timer);
7274
api.logger.error(
73-
`tailwindcss generate failed after ${CHECK_TIMEOUT_UNIT_SECOND} seconds, please check your tailwind.css and tailwind.config.js`,
75+
`tailwindcss generate failed after ${CHECK_TIMEOUT} seconds, please check your tailwind.css and tailwind.config.js`,
7476
);
7577
process.exit(1);
7678
}
77-
}, CHECK_TIMEOUT_UNIT_SECOND * 1000);
79+
}, CHECK_TIMEOUT * 1000);
7880
}
7981
});
8082
});

0 commit comments

Comments
 (0)