mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 01:08:47 +02:00
feat(build): add JavaScript minification support and use minified loading.js
- Add `minify-js` target to Makefile that minifies JavaScript files in internal/ - Update `build` and `run` targets to run minification before building/running - Replace `html/loading.js` embed with `html/loading-min.js` in loading_page.go This change optimizes the loading page performance by embedding minified JavaScript instead of the full source file. The Makefile now automatically generates minified versions of JavaScript files during build and run operations.
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -44,4 +44,7 @@ dev-data/
|
|||||||
|
|
||||||
RELEASE_NOTES.md
|
RELEASE_NOTES.md
|
||||||
CLAUDE.md
|
CLAUDE.md
|
||||||
.kilocode/**
|
.kilocode/**
|
||||||
|
|
||||||
|
# minified files
|
||||||
|
**/*-min.*
|
||||||
16
Makefile
16
Makefile
@@ -117,12 +117,21 @@ mod-tidy:
|
|||||||
cd ${PWD}/$$path && go mod tidy; \
|
cd ${PWD}/$$path && go mod tidy; \
|
||||||
done
|
done
|
||||||
|
|
||||||
build:
|
minify-js:
|
||||||
|
for file in $$(find internal/ -name '*.js' | grep -v -- '-min\.js$$'); do \
|
||||||
|
ext="$${file##*.}"; \
|
||||||
|
base="$${file%.*}"; \
|
||||||
|
min_file="$${base}-min.$$ext"; \
|
||||||
|
echo "minifying $$file -> $$min_file"; \
|
||||||
|
bunx --bun uglify-js $$file --compress --mangle --output $$min_file; \
|
||||||
|
done
|
||||||
|
|
||||||
|
build: minify-js
|
||||||
mkdir -p $(shell dirname ${BIN_PATH})
|
mkdir -p $(shell dirname ${BIN_PATH})
|
||||||
go build -C ${PWD} ${BUILD_FLAGS} -o ${BIN_PATH} ./cmd
|
go build -C ${PWD} ${BUILD_FLAGS} -o ${BIN_PATH} ./cmd
|
||||||
${POST_BUILD}
|
${POST_BUILD}
|
||||||
|
|
||||||
run:
|
run: minify-js
|
||||||
cd ${PWD} && [ -f .env ] && godotenv -f .env go run ${BUILD_FLAGS} ./cmd
|
cd ${PWD} && [ -f .env ] && godotenv -f .env go run ${BUILD_FLAGS} ./cmd
|
||||||
|
|
||||||
dev:
|
dev:
|
||||||
@@ -140,9 +149,6 @@ benchmark:
|
|||||||
sleep 1
|
sleep 1
|
||||||
@./scripts/benchmark.sh
|
@./scripts/benchmark.sh
|
||||||
|
|
||||||
dev-run: build
|
|
||||||
cd dev-data && ${BIN_PATH}
|
|
||||||
|
|
||||||
rapid-crash:
|
rapid-crash:
|
||||||
docker run --restart=always --name test_crash -p 80 debian:bookworm-slim /bin/cat &&\
|
docker run --restart=always --name test_crash -p 80 debian:bookworm-slim /bin/cat &&\
|
||||||
sleep 3 &&\
|
sleep 3 &&\
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ var loadingPageTmpl = template.Must(template.New("loading_page").Parse(string(lo
|
|||||||
//go:embed html/style.css
|
//go:embed html/style.css
|
||||||
var cssBytes []byte
|
var cssBytes []byte
|
||||||
|
|
||||||
//go:embed html/loading.js
|
//go:embed html/loading-min.js
|
||||||
var jsBytes []byte
|
var jsBytes []byte
|
||||||
|
|
||||||
func (w *Watcher) writeLoadingPage(rw http.ResponseWriter) error {
|
func (w *Watcher) writeLoadingPage(rw http.ResponseWriter) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user