Skip to content

Add --pattern flag for custom extensions for live reload #1261

@sedyh

Description

@sedyh

Hello. I would like to continue the topic raised in #646.
I want a flag to control the files to watch for templ to rebuild the app, I want to add other glob patterns besides *.go and .templ extensions.

Here is my layout:

assets/
├── static/
│   └── style.css
└── view/
    └── layout/
        └── base.templ <-links to style.css

The style.css can't be embedded as templ css components since they are don't support a lot of stuff like attribute selectors, media queries etc. The problem is not only related to css files but with all user configuration files so we can't just add fixed extensions.

Here is how this flag will work:
--pattern="assets/**/*.css"
--pattern="*.css"
--pattern="*.env,*.yaml"
--pattern="config/server.toml
Pretty similar to how task glob patterns are working.

Full command:

go tool templ generate --watch --proxy="..." --pattern="assets/**/*.css" --cmd="go run ./cmd/app"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions