denoland / fresh

The next-gen web framework.
https://fresh.deno.dev
MIT License
12.17k stars 623 forks source link

feat: improve tailwind deployment flow #2227

Closed marvinhagemeister closed 8 months ago

marvinhagemeister commented 8 months ago

By moving folks from twind over to the tailwind plugin we have traded support questions about "how to get twind autocompletion working?" with "my styles are not showing up in automatic mode". The tailwind plugin has a hard requirement on having a build step. We have documented this at various places and have a guide on how to set everything up, but it's much better if we float those steps from Fresh itself when we detect this.

With this PR we will prepare a .github/workflows/deploy.yml file already where the user only needs to swap out the project name.

When Fresh is started in production mode, the tailwind plugin is active and no snapshot files were loaded, then we print a helpful hint to the console:

No pre-compiled tailwind styles found.

Did you forget to run "deno task build" prior to starting the production server?

When we are running inside Deno Deploy this PR goes one step further. Since it is the first time many users might use Deno Deploy we'll also show a simple page that shows how to finish the tailwind setup. I've intentionally tried to not present this as a warning but rather as a "finishing" step to avoid scaring users off. It's not the prettiest page, but it's good enough for now.

Screenshot 2024-01-09 at 23 41 27

Fixes https://github.com/denoland/fresh/issues/2223

liigo commented 8 months ago

There're still complex steps. And maybe it violates https://deno.com/blog/you-dont-need-a-build-step which i think is a regress.

marvinhagemeister commented 8 months ago

@liigo sounds like you'd enjoy the existing twind plugin more than the tailwind plugin. As communicated in past Fresh blog posts already a build step overall is necessary to have a fast site. The main goal now is to make that as smooth as possible from a UX perspective. Long term we're hoping to enhance the Deno Deploy platform to have run the build step there, so that user's don't need to configure anything. But there is no timeline on that yet.

For folks who dislike the build step I'd recommend staying with twind.