From e09e7d5457c0874e1e67e606aa417daec3767f9a Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Sat, 31 Oct 2020 23:17:54 +0100 Subject: [PATCH] Add svgcleaner step for svg minification Reduce the size of the svg on build with ~ 50% by using svgcleaner. --- .gitlab-ci.yml | 2 +- Makefile | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 975b047..9d61498 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@ image: "archlinux:latest" dist: script: - - pacman -Syu --needed --noconfirm yarn ruby-sass make git + - pacman -Syu --needed --noconfirm yarn ruby-sass make git svgcleaner - make - make dist after_script: diff --git a/Makefile b/Makefile index 8c65ea5..283f8e1 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ PORT ?= 9966 HOST ?= localhost VERSION ?= $(shell git describe --tags --always --dirty --match=v* 2>/dev/null | sed 's/^v//' || \ cat $(CURDIR)/.version 2> /dev/null || echo 0.0.0-unreleased) +ARCHLOGO = public/archlogo.8a05bc7f6cd1.svg all: vendor @@ -33,7 +34,8 @@ dist: vendor @mkdir -p "dist/${PACKAGE_NAME}-${VERSION}" cp -avf public/index.html "dist/${PACKAGE_NAME}-${VERSION}/index.html" # TODO: cache-invalidation with version string replaced in html file - cp -Lvf public/favicon.ico public/*.svg -t "dist/${PACKAGE_NAME}-${VERSION}/" + svgcleaner ${ARCHLOGO} "$dist/${PACKAGE_NAME}-${VERSION}/${ARCHLOGO}" + cp -vf public/favicon.ico -t "dist/${PACKAGE_NAME}-${VERSION}/" $(SASS) -t compressed src/style.scss "dist/${PACKAGE_NAME}-${VERSION}/bundle.css" $(YARN) run -s browserify -t babelify src/index.js | $(YARN) run -s terser --compress --mangle > "dist/${PACKAGE_NAME}-${VERSION}/bundle.js" cd dist && tar --owner=0 --group=0 -czvf ${PACKAGE_NAME}-${VERSION}.tar.gz "${PACKAGE_NAME}-${VERSION}" -- GitLab