54 lines
1.8 KiB
Makefile
54 lines
1.8 KiB
Makefile
# run templ generation in watch mode to detect all .templ files and
|
|
# re-create _templ.txt files on change, then send reload event to browser.
|
|
# Default url: http://localhost:7331
|
|
live/templ:
|
|
templ generate --watch --proxy="http://localhost:9512" --open-browser=false -v
|
|
|
|
build/templ:
|
|
templ generate
|
|
|
|
# run air to detect any go file changes to re-build and re-run the server.
|
|
live/server:
|
|
go run github.com/air-verse/air@v1.61.1 \
|
|
--build.cmd "go build -o tmp/bin/main" --build.bin "tmp/bin/main" --build.delay "100" \
|
|
--build.exclude_dir "node_modules" \
|
|
--build.include_ext "go" \
|
|
--build.stop_on_error "false" \
|
|
--misc.clean_on_exit true
|
|
|
|
# run tailwindcss to generate the *.css bundle in watch mode.
|
|
live/tailwind:
|
|
npx tailwindcss -i ./view/styles/* -o ./assets/global.css
|
|
npx tailwindcss -o ./assets/styles.css --watch
|
|
|
|
build/tailwind:
|
|
npx tailwindcss -i ./view/styles/* -o ./assets/global.css --minify
|
|
npx tailwindcss -o ./assets/styles.css --minify
|
|
|
|
# run esbuild to generate the index.js bundle in watch mode.
|
|
live/esbuild:
|
|
npx esbuild js/index.ts --bundle --outdir=assets/ --watch=forever
|
|
|
|
build/esbuild:
|
|
npx esbuild js/index.ts --bundle --outdir=assets/ --minify
|
|
|
|
# watch for any js or css change in the assets/ folder, then reload the browser via templ proxy.
|
|
live/sync_assets:
|
|
go run github.com/air-verse/air@v1.61.1 \
|
|
--build.cmd "templ generate --notify-proxy" \
|
|
--build.bin "true" \
|
|
--build.delay "100" \
|
|
--build.exclude_dir "" \
|
|
--build.include_dir "assets" \
|
|
--build.include_ext "js,css"
|
|
|
|
# start all 5 watch processes in parallel.
|
|
live:
|
|
ENVIRONMENT="DEVELOPMENT" make -j5 live/tailwind live/templ live/server live/esbuild live/sync_assets
|
|
|
|
# ENABLE: https://templ.guide/syntax-and-usage/raw-go/
|
|
# https://templ.guide/commands-and-tools/live-reload-with-other-tools/
|
|
|
|
build:
|
|
make -j3 build/tailwind build/templ build/esbuild
|
|
go build -ldflags="-s -w"
|