Available via npm
yarn global add rustywind
or
npm install -g rustywind
or
Install from homebrew (mac and linux):
brew install avencera/tap/rustywind
or
Install from crates.io:
cargo install rustywind
or
cargo binstall rustywind
or
Install from a github release:
curl -LSfs https://avencera.github.io/rustywind/install.sh | sh -s -- --git avencera/rustywind
or
Download a release directly from github: github.com/avencera/rustywind/releases
or
You can use the dockerized version
docker run --rm -v $PWD:/app avencera/rustywind:latest <rustywind arguments>
Run rustywind with a path to output updated file contents to the terminal:
rustywind .
If you want to reorganize all classes in place, and change the files run with the --write flag
rustywind --write .
Run rustywind with a path and the --dry-run to get a list of files that will be changed:
rustywind --dry-run .
Run rustywind on your STDIN:
echo "<FILE CONTENTS>" | rustywind --stdin
RustyWind infers template syntax from file extensions. Override it when a file uses a different language:
rustywind --language svelte Component.html
Provide a filename when sorting standard input so RustyWind can infer its template syntax:
cat Component.svelte | rustywind --stdin --stdin-filename Component.svelte
Supported language profiles are HTML, JSX/TSX, Svelte, Astro, Django, Jinja, Twig, Liquid,
Handlebars, ERB, EJS, PHP, Blade, Lit, and Ruby. JSX and TSX program text, comments, and dynamic
attributes are preserved while directly quoted class and className attributes are sorted.
Astro frontmatter, expressions, dynamic class attributes, and class:list directives are
preserved while static quoted class attributes are sorted. Files with
unrecognized extensions use conservative legacy-compatible extraction: simple static class
attributes are sorted, while template-looking attributes remain unchanged. Because a plain .html
extension does not identify its template engine, attributes with template syntax are left unchanged
unless a profile such as --language django is selected.
Run in CI, exit with error if unsorted classes are found:
rustywind --check-formatted .
Add --json to any of these modes to print a single machine-readable JSON document instead of the
human output:
rustywind --check-formatted --json .rustywind --dry-run --json .rustywind --write --json .echo "<FILE CONTENTS>" | rustywind --stdin --json
Bare rustywind --json . behaves like --dry-run --json and never writes files. Unlike the human
dry run, dry-run JSON includes the full formatted content of every file that would change under
proposed_changes, so automation can apply the result without a second run. Each document reports
ok (formatting is clean and nothing failed; for --write, every write succeeded) and an errors
array of {path, message} entries for unreadable files or failed directory walks. The exit code is
1 when --check-formatted finds unformatted files, and in every JSON mode when errors is
non-empty; dry-run and stdin JSON still exit 0 when changes are merely proposed.
Run RustyWind with a custom sorter. The config_file.json should have a top level entry of sortOrder
which is an array with the classes listed in the order you want them sorted.
rustywind --config-file config_file.json
Use with tailwind prettier plugin
-
rustywind --output-css-file <path to the tailwind generated css file> -
rustywind --vite-css <url to the css generated by vite>
Usage: rustywind [OPTIONS] [PATH]...
Run rustywind with a path to get a list of files that will be changed
rustywind . --dry-run
If you want to reorganize all classes in place, and change the files run with the `--write` flag
rustywind --write .
To print only the file names that would be changed run with the `--check-formatted` flag
rustywind --check-formatted .
If you want to run it on your STDIN, you can do:
echo "<FILE CONTENTS>" | rustywind --stdin
Add `--json` to check, preview, write, or stdin modes for machine-readable output
rustywind --check-formatted --json .
Arguments:
[PATH]...
A file or directory to run on
Options:
--stdin
Uses stdin instead of a file or folder
--write
Changes the files in place with the reorganized classes
--dry-run
Prints out the new file content with the sorted classes to the terminal
--check-formatted
Checks if the files are already formatted, exits with 1 if not formatted
--json
Emits one machine-readable JSON document
--allow-duplicates
When set, RustyWind will not delete duplicated classes
--config-file <CONFIG_FILE>
When set, RustyWind will use the config file to derive configurations. The config file current only supports json with one property sortOrder, e.g. { "sortOrder": ["class1", ...] }
--output-css-file <OUTPUT_CSS_FILE>
When set RustyWind will determine the sort order by the order the class appear in the the given css file
--vite-css <VITE_CSS>
When set RustyWind will determine the sort order by the order the class appear in the CSS file that vite generates.
Please provide the full URL to the CSS file ex: `rustywind --vite-css "http://127.0.0.1:5173/src/assets/main.css" . --dry-run`
Note: This option is experimental and may be removed in the future.
--skip-ssl-verification
When set, RustyWind will skip SSL verification for the vite_css option
--ignored-files <IGNORED_FILES>
When set, RustyWind will ignore this list of files
--custom-regex <CUSTOM_REGEX>
Uses a custom regex whose `classes` or first capture contains the class list
--class-wrapping <CLASS_WRAPPING>
Specifies how individual classes are wrapped
[possible values: no-wrapping, comma-single-quotes, comma-double-quotes]
-p, --tailwind-prefix <TAILWIND_PREFIX>
Tailwind prefix used when sorting classes, e.g. tw for tw: or tw- classes
-l, --language <LANGUAGE>
Source language to use for all inputs, overriding filename inference
[possible values: html, svelte, astro, jsx, tsx, django, jinja, twig, liquid, handlebars, erb, ejs, php, blade, lit, ruby]
-f, --stdin-filename <PATH>
Filename used to infer the source language of stdin
--quiet
Do not print log messages
-h, --help
Print help (see a summary with '-h')
-V, --version
Print versionInspired by Ryan Heybourn's headwind vscode plugin. This is a CLI tool that will look through your project and sort all Tailwind CSS classes.
It will also delete any duplicate classes it finds.
See RELEASE.md for release directions.