CLI as a persistent / sidecar process #19092
Replies: 1 comment 1 reply
-
Hey! Do you even need any of the file system access in your project? If you only want to pipe in stdin, it might be easier for you to use the core A good start here would be to look at the CLI source code: https://github.com/tailwindlabs/tailwindcss/blob/main/packages/%40tailwindcss-cli/src/commands/build/index.ts#L209-L215 the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
I am currently working on a Rust-based static site generator. As such, to add support for Tailwind, I'm spawning the CLI with the arguments I need and stuff. This is good and fine, however the overhead of spawning a Node process is absolutely insane compared to how long my builds are generally taking. It's faster for my SSG to generate thousands of pages than starting a Node process. In most cases Tailwind takes 99% of the build time of projects using my SSG.
To remediate this, I implemented a system where I call Tailwind CLI in the background waiting for stdin and whenever I need it, I send some stuff through, get the stdout, etc.
This works but it's very clumsy for multiple reasons:
What I'd like to see is a way to run the CLI as a permanent process and being able to send it messages through stdin. Could be JSON or some other format, something like:
Then the CLI would output something to stdout with the result (if no
output
is specified, then the content would be included in said result, otherwise something like{"status": "done"}
or something. I'd be willing to help implement this if the idea is accepted.Beta Was this translation helpful? Give feedback.
All reactions