Crate snowfinch

Crate snowfinch 

Source
Expand description

§snowfinch

A simple Rust proc-macro wrapper around tailwindcss.

§about

snowfinch is a very simple proc-macro wrapper around the fantastic tailwindcss framework. This crate aims to make it easy and ergonomic to quickly compile any utility classes into your project. A sha256 digest is also calculated and embedded with the stylesheet to aid with web content caching.

Note that this crate does not include the actual tailwindcss binary, as that would exceed the crates.io maximum of 10MB.

§getting started

To start using snowfinch, you’ll first need to add our package to your Cargo.toml manifest:

cargo add snowfinch

Then you can compile a stylesheet into a const; Refer to the official tailwindcss documentation for guidance on the stylesheet itself.

// Here we use `tailwindcss` to compile a stylesheet called `tailwind.css`
// in the parent directory to this source file.
const STYLESHEET: Stylesheet<'static> = snowfinch::compile!("../tailwind.css");

fn main() {
  // Trick `tailwindcss` into generating a few utilities:
  // class="bg-slate-400 font-bold p-8"

  // Here we can get the generated stylesheet source, which should, among
  // other things contain the css for our utilities written above.
  let src = STYLESHEET.src();

  // We can also retrieve the sha256 digest of the stylesheet source, which
  // may be helpful for caching.
  let digest = STYLESHEET.digest();
}

Macros§

compile

Structs§

Stylesheet
Represents the stylesheet compiled by the tailwindcss binary through [snowfinch::compile!].