| 74 | const CONFIG_EXTENSIONS = ["ts", "js", "mjs"]; |
| 75 | |
| 76 | async function findTailwindConfigFile(directory: string): Promise<string> { |
| 77 | let dir = directory; |
| 78 | while (true) { |
| 79 | for (let i = 0; i < CONFIG_EXTENSIONS.length; i++) { |
| 80 | const ext = CONFIG_EXTENSIONS[i]; |
| 81 | const filePath = path.join(dir, `tailwind.config.${ext}`); |
| 82 | try { |
| 83 | const stat = await Deno.stat(filePath); |
| 84 | if (stat.isFile) { |
| 85 | return filePath; |
| 86 | } |
| 87 | } catch (err) { |
| 88 | if (!(err instanceof Deno.errors.NotFound)) { |
| 89 | throw err; |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | const parent = path.dirname(dir); |
| 95 | if (parent === dir) { |
| 96 | throw new Error( |
| 97 | `Could not find a tailwind config file in the current directory or any parent directory.`, |
| 98 | ); |
| 99 | } |
| 100 | |
| 101 | dir = parent; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | async function initTailwind( |
| 106 | config: ResolvedBuildConfig, |