#tailwind #compiler #css

railwind

Tailwind compiler for utility classes written in Rust

15 releases

0.1.5 Feb 18, 2023
0.1.4 Feb 17, 2023
0.0.12 Jan 8, 2023
0.0.11 Dec 10, 2022
0.0.3 Oct 15, 2022

#1622 in Web programming

Download history 872/week @ 2024-08-03 796/week @ 2024-08-10 831/week @ 2024-08-17 965/week @ 2024-08-24 930/week @ 2024-08-31 1056/week @ 2024-09-07 1334/week @ 2024-09-14 993/week @ 2024-09-21 995/week @ 2024-09-28 987/week @ 2024-10-05 1174/week @ 2024-10-12 1046/week @ 2024-10-19 716/week @ 2024-10-26 539/week @ 2024-11-02 518/week @ 2024-11-09 553/week @ 2024-11-16

2,484 downloads per month
Used in 6 crates (2 directly)

MIT license

290KB
9K SLoC

Rust 7K SLoC // 0.0% comments Rusty Object Notation 1.5K SLoC

Railwind

Tailwind compiler rewritten in Rust

Description

The main goal, is to decouple the original Tailwind project from Node and NPM and add warning messages with some recovery in specific situations with the side goal of possibly making it even faster and smaller (Tailwind already has a standalone version, but the binary size is a whooping 35 mb).

Getting started

Installation

To install with cargo, run cargo install railwind to install the CLI.

Using railwind

To first start, generate a default railwind.config.ron file using railwind -g or railwind --generate. At the moment, the config supports only two values:

content

Similar to tailwinds option, configure a path to all your HTML templates, Rust or JS files.

extend_collection_options

The compiler reads the file extension and selects an apropriate regex or way to parse that file. For example, files ending with .html will be parsed with a regex: (?:class|className)=(?:["]\W+\s*(?:\w+)\()?["]([^"]+)["]" to extract the class names. Similarly, you can specify your own regex to parse custom files:

extend_collection_options: Some({
    "rs": Regex(r#"(?:class)=(?:["]\W+\s*(?:\w+)\()?["]([^"]+)["]"#)
})

or give hints to the compiler, for example to parse a rs file as a html file:

extend_collection_options: Some({
    "rs": Html
})

To check out what other options are available, check out the documentation or the railwind::CollectionOptions enum which can be expaned.

After setting up the config file, you can run tailwind to read the railwind.config.ron and generate a railwind.css file in the same directory. You can optionally specify a different config file with the -c flag and a different output file using the -o flag.

Authors

Contributors names and contact info

@pintariching

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

Inspiration, code snippets, etc.

Dependencies

~4–5.5MB
~106K SLoC