lambda-fairy / maud

:pencil: Compile-time HTML templates for Rust
https://maud.lambda.xyz
Apache License 2.0
2.09k stars 137 forks source link

Tailwind/railwind support #367

Closed edezhic closed 1 year ago

edezhic commented 1 year ago

Hey, really like what you're building here (the only ."truly" ."rusty" template lib afaik). Curious if you've considered 1st class support of tailwind or railwind. I feel like maud+railwind (+ maybe htmx or alike) could provide nice idiomatic dev experience with top-notch performance. I'm trying to compose a full rust stack for web dev but not a fan of yew and other heavy opionated libs

wangbinyq commented 1 year ago

I use https://twind.style/, It can run in client side, so it integerate with maud very well.

Xe commented 1 year ago

I'd like the railwind logic to run on the server though. Would I need to make some wrapper around the html macro to get things working?

lambda-fairy commented 1 year ago

To clarify, what does Tailwind support involve? I had a brief look and it seems like it's just a CSS framework.

Does support mean stripping out unused CSS classes?

edezhic commented 1 year ago

Yeah, ideally it should be relatively easy to compile the used classes at least in the release profile. I've tried railwind for that but it's extremely early stage and buggy, and things become complicated once classes aren't just hardcoded like ."some-tailwind-class" but precomputed and added as variables .(VAR)

I don't know what the best angle to approach that would be, but tailwind is probably the best css tool out there and I think it would be nice to make Maud play well with it somehow

shepmaster commented 1 year ago

I'm using Tailwind with Maud (and Axum) with no changes to any of the projects. I use Parcel to build my CSS and JS which includes the Tailwind minimization. The only configuration I needed was to tell Tailwind also look at my Rust source files.

edezhic commented 1 year ago

Looks like the problem is just with railwind, hopefully it will catch up at least with core tailwind features eventually. But on maud's end everything looks ok. I'll switch to maud+grass for now. Thanks for your attention folks

imbolc commented 1 year ago

I'll switch to maud+grass for now

@edezhic I'm not sure how Grass relates to Tailwind. Have you completely given up on Tailwind?

Wragdan commented 3 months ago

I added the tailwind build to my build step:

// build.rs
fn main() {
    let tailwind_cmd = "npx tailwindcss -i index.css -o assets/index.css";

    let path = fs::canonicalize(".");

    let path = match path {
        Ok(p) => p,
        Err(e) => panic!("{}", e),
    };

    std::process::Command::new("zsh")
        .current_dir(path)
        .arg("-c")
        .arg(tailwind_cmd)
        .spawn()
        .expect("failed running tailwind");
}

Not the best code, but I'm still in dev, so not production code for now. If you run cargo watch -x run it compiles on each file change.