Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live reloading #1

Closed
3 tasks done
darccio opened this issue Oct 1, 2023 · 8 comments
Closed
3 tasks done

Live reloading #1

darccio opened this issue Oct 1, 2023 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@darccio
Copy link

darccio commented Oct 1, 2023

Required check list:

  • I didn't find in the repository's issues section a similar bug.
  • I understand, this is an Open Source and not-for-profit product.
  • This is not about a third-party project, framework, or technology.

Is your feature request related to a problem? Please describe.

Gowebly seems a nice approach to web development in Go, without going down the road of another framework. The only thing I missed while testing it was live reloading for Tailwind.

As Gowebly focuses on reducing manual work in boilerplate, I think it's worth to dedicate time to include support for air as the most popular solution for this.

Describe the solution you'd like:

The main focus would be to run npx tailwind -i "assets/styles.css" -o "static/styles.css" --watch everytime we change styles.

I would appreciate your thoughts on this, and how to implement it so other commands can run on modification of other files.

@darccio darccio added the enhancement New feature or request label Oct 1, 2023
@17twenty
Copy link

17twenty commented Oct 2, 2023

You'd be better off using the static binary for tailwind.
I'm using that for my own project similar to gowebly but damn if I was too late sharing it with the world!

@koddr
Copy link
Contributor

koddr commented Oct 2, 2023

Hi @darccio,

You'll laugh, but when developing the 1.0.0 version of the CLI, I wanted to include some kind of library for live-reloading Go code. Yes, this is in the plans for the next versions.

The only thing that confuses me is the implementation:

  1. Can air work without config (as is)? I wouldn't want to add another config to the project folder, as it would put even more cognitive load on the developer.
  2. How to make parallel rebuild of styles (via npx|bunx with --watch option) and Go-code (via air)? Run in different goroutines with synchronization of process termination command (via ctrl+c) or… somehow else?

I would be glad to have a discussion (or even PR) on this topic, in order to make a truly correct decision on the development of the project. The main goal is to make it as convenient and simple as possible for the end developer 😉

@koddr
Copy link
Contributor

koddr commented Oct 2, 2023

Hi @17twenty,

I'm not really clear about which static binary for tailwind you're talking about?

Please expand the topic completely, if you can 🤔

@17twenty
Copy link

17twenty commented Oct 2, 2023

@koddr there's a standalone that doesn't require npm - https://github.com/tailwindlabs/tailwindcss/releases/tag/v3.3.3

You can use it in dev/JIT mode as well as final bundle. It's very good and my project autofetched the correct one per architecture 😅

I'd recommend that over the NPM dependency to keep things subjectively cleaner and self contained

@17twenty
Copy link

17twenty commented Oct 2, 2023

https://tailwindcss.com/blog/standalone-cli the article even recommends it for non NPM dependent projects 💖

@koddr
Copy link
Contributor

koddr commented Oct 3, 2023

Hi, @darccio @17twenty

Fun fact: Tailwind CSS CLI (via npx or bunx) with --watch option doesn't work correctly from the Go code.

For example, this code fails:

cmd := exec.Command("npx", "tailwindcss", "-i", "./assets/styles.css", "-o", "./static/styles.css", "--watch")

cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

cmd.Run()

The code returns nothing to Stdout, and does nothing with the style files.

But, for example, UnoCSS CLI (@unocss/cli) works perfectly:

cmd := exec.Command("npx", "@unocss/cli", "\"**/*.{html,css}\"", "-o", "./static/styles.css", "-w")

// ...
after running go run

(👆 this is the result of a call @unocss/cli from Go-code)

I tried implementing this via goroutine, but the effect was exactly the same: goroutine terminates immediately after the call if the --watch(or -w) option is present.

This behavior casts great doubt on the feasibility of implementing a live-reload mode for Tailwind CSS. Unfortunately.

@koddr
Copy link
Contributor

koddr commented Oct 4, 2023

Please, check version v1.2.0.

It already has live-reloading enabled by default in the gowebly run command (with npm|bun run watch from package.json).

I'm still thinking about the possibility of adding this mode for Go code.

I'll close this issue for now, but you can always reopen it if you have any thoughts on this! 😉

@koddr koddr closed this as completed Oct 4, 2023
@darccio
Copy link
Author

darccio commented Oct 10, 2023

@koddr Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants