tailwindcss-atomic
Rust compiler that turns compiled Tailwind CSS into atomic hashed classes.
This crate is the engine behind tailwindcss-atomic. It has no JavaScript or wasm-bindgen dependency: use it from a CLI, a native plugin, or wrap it in WASM yourself.
Usage
[]
= "2.0"
use ;
let out = atomicize_stylesheet?;
// "flex" -> "_a1b2c3"
let classes = rewrite_class_string;
let html = rewrite_html_classes;
atomicize_stylesheet returns:
class_map— original utility → space-separated atomic hashescss— full stylesheet with utilities replaced (keeps@theme,:root,@media,@supports, custom components)css_rules— only the hashed atomic ruleschanged— whether anything was rewritten
Custom classes that are not Tailwind-shaped (.header-signin, .btn-notch) and component ::before / ::after rules are left intact. looks_like_tailwind_utility is the classifier the JS plugin uses so it does not keep a second copy of Tailwind prefixes.
WASM / bundlers
The npm package tailwindcss-atomic ships WebAssembly bindings from the tailwindcss-atomic-wasm crate in this repo. You do not need this crate unless you are embedding the compiler in Rust.
License
MIT