-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
cmd: add --notify
to generate --watch
in cli
#656
Comments
That sounds like a useful feature to add. In terms of implementation, it feels to me that the proxy should start an additional route ( templ/cmd/templ/generatecmd/proxy/proxy.go Lines 110 to 126 in dbbb53b
With that in place, I think the name would be less ambiguous if it was Other implementation notes would be that it's important to update the hot reload docs to cover this, and ensure we have an integration test added to the hot reload integration test suite. |
@jackielii - if you want to implement this, I'd happily take a PR. If not, just mention it here, and it will be free for someone else to pick up. I want to focus on a new CSS parser implementation, as well as reviewing other PRs, replying to issues etc. |
--notify
to generate --watch
in cli--notify
to generate --watch
in cli
I noticed this is document in the live reload docs but not mentioned on the CLI page. |
The problem
Templ handles automatic reloading of browser based on SSE when it detects a file change. However, it only watches Templ related files, and rightly so. The community has come up with various methods to watch other files e.g. for Go, there is
air
andwgo
, for tailwindcss, there is tailwindcss cli. For example, this is my solution as an example:Here I start 3 watch processes:
However, the reloading of the browser doesn't always work. It sort of works for Go files, take this for an example:
In this process, go build and restart proces is usually very fast, so the reload usually happens correctly. But for reloading the
assets/styles.css
when tailwind rebuilds it, there is no right way to do it.Templ would like to stay simple to only handle its related files, see issue #646 for which I fully support. However templ should provide a way for other process to notify there is a change so that users can progmatically send the reload event when necessary.
Proposal
Add
--notify
togenerate
subcommand. An example would look like this:It should send an reload event via SSE and exit immediately. By default, it sends to port 7331, for an alternative port,
-proxyport
can be specified.If this is implemented, one can simply add another directive in the makefile like so:
Alternatives
Alternative I considered is browser-sync, however it can't handle templ related generation efficiently.
The text was updated successfully, but these errors were encountered: