diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-09-21 10:40:30 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-09-21 10:40:30 +0200 |
commit | 0f6d9ee6b2c871742ae9f63e92665aa56991eb52 (patch) | |
tree | fe5f03022aa5b7c1aada9fab81791e1220035957 | |
parent | 70d33474ae169d6ef937eb65e3fedae9398152bf (diff) |
Perform CSS minification
-rw-r--r-- | Makefile | 22 | ||||
-rw-r--r-- | src/http.go | 2 | ||||
-rw-r--r-- | src/templates/base.html.tmpl | 2 |
3 files changed, 15 insertions, 11 deletions
@@ -1,15 +1,16 @@ -templates = $(shell find src/templates -name '*.tmpl') -gofiles = $(shell find main.go src -name '*.go') +cssfiles := $(shell find static -name '*.css' -not -name '*.min.css') +cssfiles := $(cssfiles:.css=.min.css) +gofiles := $(shell find main.go src -name '*.go') +templates := $(shell find src/templates -name '*.tmpl') -exttmpl = $(wildcard cmd/exttmpl/*.go) -mfmt = $(wildcard cmd/mfmt/*.go) +exttmpl := $(wildcard cmd/exttmpl/*.go) +mfmt := $(wildcard cmd/mfmt/*.go) all: euro-cash.eu exttmpl mfmt -euro-cash.eu: $(templates) $(gofiles) +euro-cash.eu: $(cssfiles) $(templates) $(gofiles) go build -# Generating translations is rather slow; so don’t do that by default all-i18n: exttmpl go generate ./src find . -name out.gotext.json | mcp -b sed s/out/messages/ @@ -21,14 +22,17 @@ exttmpl: $(exttmpl) mfmt: $(mfmt) go build ./cmd/mfmt +%.min.css: %.css + lightningcss -m $< -o $@ + watch: ls euro-cash.eu | entr -r ./euro-cash.eu -no-email -port $${PORT:-8080} -# Build a release tarball for easy deployment -# TODO: Minify CSS release: all-i18n [ -n "$$GOOS" -a -n "$$GOARCH" ] - tar -cf euro-cash.eu-$$GOOS-$$GOARCH.tar.gz euro-cash.eu data/ static/ + find data static -type f \ + \( -not -name '*.css' -or -name '*.min.css' \) \ + -exec tar -cf euro-cash.eu-$$GOOS-$$GOARCH.tar.gz euro-cash.eu {} + clean: find . -type f \( \ diff --git a/src/http.go b/src/http.go index 395aefd..ca286de 100644 --- a/src/http.go +++ b/src/http.go @@ -27,7 +27,7 @@ func Run(port int) { mux.Handle("GET /designs/", fs) mux.Handle("GET /favicon.ico", fs) mux.Handle("GET /fonts/", fs) - mux.Handle("GET /style.css", fs) + mux.Handle("GET /style.min.css", fs) mux.Handle("GET /coins/mintages", chain( firstHandler, i18nHandler, diff --git a/src/templates/base.html.tmpl b/src/templates/base.html.tmpl index ee4dfec..2a33cc3 100644 --- a/src/templates/base.html.tmpl +++ b/src/templates/base.html.tmpl @@ -3,7 +3,7 @@ <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <link href="/style.css" type="text/css" rel="stylesheet"> + <link href="/style.min.css" type="text/css" rel="stylesheet"> <title>{{ .T "Euro Cash" }}</title> <script type="text/javascript"> const $ = q => document.querySelector(q); |