Replies: 2 comments
-
|
An example of the process spawning .NET code. Running the outputted command manually in the terminal works perfectly. private async Task RunTailwindCliAsync(string outputCssPath)
{
var currentWorkingDir = AppDomain.CurrentDomain.BaseDirectory;
var startInfo = new ProcessStartInfo
{
FileName = "./tailwindcss", // Adjust for your platform if necessary
Arguments = $"--cwd \"{currentWorkingDir}\" --input \"tailwind.base.css\" -o \"output.css\" --minify",
RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardInput = true,
UseShellExecute = false,
CreateNoWindow = true,
WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory
};
// Initialize process in a try block to ensure disposal if exception is thrown
using var process = new Process();
process.StartInfo = startInfo;
_logger.LogInformation("Running Tailwind CLI: {Command} {Arguments}", startInfo.FileName, startInfo.Arguments);
process.Start();
Task<string> readOutputTask = process.StandardOutput.ReadToEndAsync();
Task<string> readErrorTask = process.StandardError.ReadToEndAsync();
await process.WaitForExitAsync();
// Await the reading tasks to ensure all output is consumed
string output = await readOutputTask;
string error = await readErrorTask;
if (process.ExitCode != 0)
{
throw new InvalidOperationException($"Tailwind CLI failed with exit code {process.ExitCode}: {error}");
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
As an FYI, only the file scanning portion of Tailwind is written in Rust. The other parts of it are compiled to JavaScript from TypeScript. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a setup (and albeit a unique one) where I'd like to dynamically generate tailwind classes for an incoming html blob (string).
Right now I've tried a getto solution of writing the blob to disk into a
tmpdirectory and then having the cli generate output.css where the dir is in the sources list and then read the css back in from disk.Whilst this could work in theory I have experienced some issues.
WaitForExitnever returns with the processes exit codeThe main goal here is the ability to programmatically generate tailwind classes for a given input string. As far as I know the TailwindCSS CLI is built in rust.
Some ideas to make this easier could be:
Beta Was this translation helpful? Give feedback.
All reactions