mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-28 17:32:38 +02:00
add compress_assets target to compress PNG.
It depends on zopflipng, find and xargs. Only zopflipng is tested, since it is the less common.
This commit is contained in:
parent
604f4696d8
commit
4a7c9d541d
1 changed files with 10 additions and 0 deletions
10
Makefile
10
Makefile
|
@ -6,6 +6,7 @@ DEV_STAMP = $(VENV)/.dev_env_installed.stamp
|
|||
DOC_STAMP = $(VENV)/.doc_env_installed.stamp
|
||||
INSTALL_STAMP = $(VENV)/.install.stamp
|
||||
TEMPDIR := $(shell mktemp -d)
|
||||
ZOPFLIPNG := zopflipng
|
||||
|
||||
.PHONY: all
|
||||
all: install ## Alias for install
|
||||
|
@ -47,6 +48,15 @@ test: $(DEV_STAMP) ## Run the tests
|
|||
release: $(DEV_STAMP) ## Release a new version (see https://ihatemoney.readthedocs.io/en/latest/contributing.html#how-to-release)
|
||||
$(VENV)/bin/fullrelease
|
||||
|
||||
.PHONY: compress_assets
|
||||
compress_assets: ## Compress static assets
|
||||
@which $(ZOPFLIPNG) >/dev/null || (echo "ZopfliPNG ($(ZOPFLIPNG)) is missing" && exit 1)
|
||||
mkdir $(TEMPDIR)/zopfli
|
||||
$(eval CPUCOUNT := $(shell python -c "import psutil; print(psutil.cpu_count(logical=False))"))
|
||||
# We need to go into the directory to use an absolute path as a prefix
|
||||
cd ihatemoney/static/images/; find -name '*.png' -printf '%f\0' | xargs --null --max-args=1 --max-procs=$(CPUCOUNT) $(ZOPFLIPNG) --iterations=500 --filters=01234mepb --lossy_8bit --lossy_transparent --prefix=$(TEMPDIR)/zopfli/
|
||||
mv $(TEMPDIR)/zopfli/* ihatemoney/static/images/
|
||||
|
||||
.PHONY: build-translations
|
||||
build-translations: ## Build the translations
|
||||
$(VENV)/bin/pybabel compile -d ihatemoney/translations
|
||||
|
|
Loading…
Reference in a new issue