From d3d55e294cfd0331742275f63a4ec2f353362322 Mon Sep 17 00:00:00 2001 From: Vincent Boutour Date: Thu, 3 Nov 2022 23:14:26 +0100 Subject: [PATCH] ci: Minifiy static files Signed-off-by: Vincent Boutour --- .github/workflows/build.yaml | 4 ++++ Makefile | 8 ++++++++ cmd/fibr/static/scripts/map.js | 6 +----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 776fbf76..597393ea 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -62,6 +62,10 @@ jobs: uses: actions/setup-go@v3 with: go-version: '^1.19' + - name: Minify + run: | + apt-get install minify + make build-web - name: Build run: | curl --disable --silent --show-error --location --max-time 30 "https://raw.githubusercontent.com/ViBiOh/scripts/main/bootstrap" | bash -s -- "-c" "release" diff --git a/Makefile b/Makefile index 3e72f1a7..7799b6ee 100644 --- a/Makefile +++ b/Makefile @@ -89,6 +89,14 @@ bench: build: CGO_ENABLED=0 go build -ldflags="-s -w" -installsuffix nocgo -o bin/$(APP_NAME) $(MAIN_SOURCE) +## build: Build the application. +.PHONY: build-web +build-web: + minify "cmd/fibr/static/scripts/async-image.js" > "cmd/fibr/static/scripts/async-image.min.js" && mv "cmd/fibr/static/scripts/async-image.min.js" "cmd/fibr/static/scripts/async-image.js" + minify "cmd/fibr/static/scripts/map.js" > "cmd/fibr/static/scripts/map.min.js" && mv "cmd/fibr/static/scripts/map.min.js" "cmd/fibr/static/scripts/map.js" + minify "cmd/fibr/static/scripts/navigation.js" > "cmd/fibr/static/scripts/navigation.min.js" && mv "cmd/fibr/static/scripts/navigation.min.js" "cmd/fibr/static/scripts/navigation.js" + minify "cmd/fibr/static/styles/main.css" > "cmd/fibr/static/styles/main.min.css" && mv "cmd/fibr/static/styles/main.min.css" "cmd/fibr/static/styles/main.css" + ## run: Locally run the application, e.g. node index.js, python -m myapp, go run myapp etc ... .PHONY: run run: diff --git a/cmd/fibr/static/scripts/map.js b/cmd/fibr/static/scripts/map.js index 748932d2..eb8599e5 100644 --- a/cmd/fibr/static/scripts/map.js +++ b/cmd/fibr/static/scripts/map.js @@ -97,11 +97,7 @@ async function renderMap(geoURL) { bounds.push(coord); markers.addLayer( L.circleMarker(coord).bindPopup( - ` - Image thumbnail - -
- ${f.properties.date}`, + `Image thumbnail
${f.properties.date}`, { maxWidth: 'auto', closeButton: false,