Created
May 17, 2023 18:38
-
-
Save joshdavenport/aabab07a658113cf646317f380fd4af6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Name: Tailwind Check | |
// Author: Josh Davenport-Smith | |
// Twitter: @joshdprts | |
import "@johnlindquist/kit"; | |
const b = await npm("beautify"); | |
const input = await arg({ | |
name: "Enter Tailwind classes", | |
hint: "Enter Tailwind classes to check, only supports stock theme values. Values are applied to a .output-check class.", | |
}); | |
const checkFile = `/tmp/tw-${Date.now()}.css`; | |
writeFile( | |
checkFile, | |
` | |
@tailwind base; | |
@tailwind components; | |
@tailwind utilities; | |
/*OUTPUTCHECKSTART*/ | |
.output-check { | |
@apply ${input}; | |
} | |
/*OUTPUTCHECKEND*/ | |
` | |
); | |
const { stdout } = await exec(`npx tailwindcss -i ${checkFile}`); | |
rm(checkFile); | |
const outputMatch = stdout | |
.replace(/\n/g, "") | |
.match(/\/\*OUTPUTCHECKSTART\*\/([^\/]+)\/\*OUTPUTCHECKEND\*\//); | |
const output = outputMatch[1].trim(); | |
await div(` | |
<pre class="px-2 py-2">${b(output, { format: "css" })}</code> | |
`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment