[READ-ONLY] Mirror of https://github.com/andrioid/gastro. Server Side templates, combining Go (frontmatter) and html/template (body) with full LSP support
gastro.andri.dk
golang
lsp-server
template-engine
1#!/usr/bin/env bash
2#MISE description="Run examples/gastro with Tailwind CSS rebuild on change"
3
4# Hot-reload loop for the gastro-website example.
5#
6# tailwindcss rebuilds static/styles.css when tailwind.css or
7# any scanned .gastro file changes. Wired as --asset
8# (not --build) so it ALSO runs on RELOAD-class
9# changes (template-body edits). --build only fires
10# on RESTART-class changes, so putting Tailwind
11# there would silently miss new utility classes
12# introduced by body-only edits.
13# go build rebuilds the binary against the regenerated
14# .gastro/ package after gastro watch's own codegen
15# gastro watch owns the .gastro -> .gastro/ codegen step itself,
16# which is why we don't list `gastro generate` as a
17# separate --build (it would double-run).
18#
19# We invoke tailwindcss without --minify here so dev rebuilds stay fast
20# and the un-minified output is easier to read in the browser inspector.
21# The committed static/styles.css is the *minified* output produced by
22# `go generate ./...` (see generate.go).
23
24set -euo pipefail
25cd "$(dirname "$0")/../../examples/gastro"
26
27# Bootstrap: static/styles.css is gitignored, so a fresh clone has
28# no CSS file. `gastro watch`'s first Generate copies static/ into
29# .gastro/static/ BEFORE the --asset chain has a chance to run, so
30# without this priming step the initial build would embed an empty
31# CSS asset and the first page load would 404. Subsequent .gastro
32# edits would recover, but that's a bad first impression. One sync
33# tailwindcss run here means the .gastro/static/ copy is correct
34# from the very first Generate.
35if [ ! -f static/styles.css ]; then
36 echo "bootstrap: generating static/styles.css"
37 tailwindcss -i tailwind.css -o static/styles.css
38fi
39
40exec gastro watch \
41 --asset 'tailwindcss -i tailwind.css -o static/styles.css' \
42 --build 'go build -o tmp/app .' \
43 --run 'tmp/app'