prometheus/scripts/compress_assets.sh
Julien Pivotto c901ebaf8d
ui/compress: Do not change git worktree (#10467)
This change makes sure that the git worktree is not changed while
compressing assets, making it better for local development.

To achieve this, the compression script keeps the un-compressed assets
and generates the go:embed directory when compressing the files.

A .gitignore file has been added to ignore generated files.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2022-03-20 15:08:32 +01:00

12 lines
295 B
Bash
Executable file

#!/usr/bin/env bash
#
# compress static assets
set -euo pipefail
cd web/ui
cp embed.go.tmpl embed.go
find static -type f -name '*.gz' -delete
find static -type f -exec gzip -fk '{}' \; -print0 | xargs -0 -I % echo %.gz | xargs echo //go:embed >> embed.go
echo var EmbedFS embed.FS >> embed.go