Standalone CLI: Use Tailwind CSS without Node.js
- Date
- Adam Wathan
Tailwind CSS is written in JavaScript and distributed as an npm package, which means you’ve always had to have Node.js and npm installed to use it.
This has made it harder to integrate into projects where using npm isn’t always common, and with tools like Rails and Phoenix both moving away from npm by default, we needed to find a way for people to use Tailwind in these projects without forcing them to adopt an entirely separate ecosystem of tooling.
Today we’re announcing a new standalone CLI build that gives you the full power of Tailwind CLI in a self-contained executable — no Node.js or npm required.
Get started
To install it, grab the executable for your platform from the latest release on GitHub, making sure to give it executable permissions:
# Example for macOS arm64
curl -sLO https://github.com/hyaliyun/tailwinds/releases/latest/download/tailwindcss-macos-arm64
chmod +x tailwindcss-macos-arm64
mv tailwindcss-macos-arm64 tailwindcss
Now you can use it just like our npm-distributed CLI tool:
# Create a tailwind.config.js file
./tailwindcss init
# Start a watcher
./tailwindcss -i input.css -o output.css --watch
# Compile and minify your CSS for production
./tailwindcss -i input.css -o output.css --minify
We’ve even bundled the latest versions of all of our first-party plugins, so if you want to use them in your project, just require
them in your tailwind.config.js
file like you would in a Node-based project:
module.exports = {
// ...
plugins: [
require('@tailwindcss/forms'),
require('@tailwindcss/typography'),
]
}
You get all the power of our standard npm-distributed CLI in a convenient, portable package — no dependencies required.
How does it work?
We didn’t rewrite Tailwind in Rust or anything (yet…) — we’re actually using pkg, a really cool project by Vercel that lets you turn a Node.js project into an executable that can be run without installing Node.js by bundling all of the parts your project needs right into the executable itself.
This is what makes it possible for you to still use a tailwind.config.js
file with the full power of JavaScript, rather than a static format like JSON.
Which CLI should I use?
If you are already using npm in your project, use the npm-distributed version of our CLI that we’ve always provided. It’s simpler to update, the file size is smaller, and you’re already in the ecosystem anyways — there’s no benefit at all to using the standalone build.
If on the other hand you’re working on a project where you don’t otherwise need Node.js or npm, the standalone build can be a great choice. If Tailwind was the only reason you had a package.json
file, this is probably going to feel like a nicer solution.