Skip to content

Commit 514e2e6

Browse files
committed
Add air-based dev mode for automatic rebuilds
Add .air.toml config and a `just dev` target that watches .go and .templ files and automatically regenerates templates and rebuilds the application on changes.
1 parent f841900 commit 514e2e6

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

.air.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[build]
2+
pre_cmd = ["go tool templ generate"]
3+
cmd = "go build -tags production -o ./tmp/pkgstatsd ."
4+
entrypoint = ["./tmp/pkgstatsd"]
5+
include_ext = ["go", "templ"]
6+
exclude_dir = [".idea", "dist", "node_modules", "tmp"]
7+
exclude_regex = ["_templ\\.go$"]

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ the Arch Linux package statistics website.
88
# Setup
99
1. Run `just init` to install dependencies, build and generate fixtures
1010
2. Run `just run` to start the application locally
11-
3. Run `just` for a full list of available commands
11+
3. Run `just dev` to watch for template and Go changes and rebuild automatically (requires [air](https://github.com/air-verse/air))
12+
4. Run `just` for a full list of available commands
1213

1314
# Contributions
1415
For contributing you'll probably want to test your changes at least once

justfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ build: build-assets build-templates
3636
run:
3737
go run -tags production .
3838

39+
# watch for template and Go changes and rebuild automatically
40+
dev:
41+
air
42+
3943
# run all tests
4044
test:
4145
go test ./...

0 commit comments

Comments
 (0)