From 0b7012b4d25671e0bc72e28e56aefcb1fa10f0f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Sun, 24 May 2020 15:42:29 +0200 Subject: [PATCH 1/2] MAPG-62 minify SVG files with html-minifier put minify calls into separate sh script --- scripts/install.sh | 7 +++---- scripts/minify.sh | 9 +++++++++ scripts/update.sh | 5 ++--- 3 files changed, 14 insertions(+), 7 deletions(-) create mode 100755 scripts/minify.sh diff --git a/scripts/install.sh b/scripts/install.sh index 317b5f5..d7aaa17 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -5,7 +5,7 @@ ROOT_DIR=$(dirname $(readlink -f "$0"))/.. . ${ROOT_DIR}/.env if [ -f ${ROOT_DIR}/installed ]; then - echo "Mapguesser is already installed! To force reinstall, delete file 'installed' from the root directory!" + echo "MapGuesser is already installed! To force reinstall, delete file 'installed' from the root directory!" exit 1 fi @@ -14,10 +14,9 @@ echo "Installing MapGuesser DB..." mysql --host=${DB_HOST} --user=${DB_USER} --password=${DB_PASSWORD} ${DB_NAME} < ${ROOT_DIR}/db/mapguesser.sql if [ -z "${DEV}" ] || [ "${DEV}" -eq "0" ]; then - echo "Uglifying JS and CSS files..." + echo "Minifying JS, CSS and SVG files..." - uglifyjs ${ROOT_DIR}/public/static/js/mapguesser.js -c -m -o ${ROOT_DIR}/public/static/js/mapguesser.js - cleancss ${ROOT_DIR}/public/static/css/mapguesser.css -o ${ROOT_DIR}/public/static/css/mapguesser.css + ${ROOT_DIR}/scripts/minify.sh fi touch ${ROOT_DIR}/installed diff --git a/scripts/minify.sh b/scripts/minify.sh new file mode 100755 index 0000000..79c1bb5 --- /dev/null +++ b/scripts/minify.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +ROOT_DIR=$(dirname $(readlink -f "$0"))/.. + +. ${ROOT_DIR}/.env + +uglifyjs ${ROOT_DIR}/public/static/js/mapguesser.js -c -m -o ${ROOT_DIR}/public/static/js/mapguesser.js +cleancss ${ROOT_DIR}/public/static/css/mapguesser.css -o ${ROOT_DIR}/public/static/css/mapguesser.css +html-minifier ${ROOT_DIR}/public/static/img/loading.svg --collapse-whitespace --remove-comments -o ${ROOT_DIR}/public/static/img/loading.svg diff --git a/scripts/update.sh b/scripts/update.sh index 2c435a5..46e0cd4 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -5,8 +5,7 @@ ROOT_DIR=$(dirname $(readlink -f "$0"))/.. . ${ROOT_DIR}/.env if [ -z "${DEV}" ] || [ "${DEV}" -eq "0" ]; then - echo "Uglifying JS and CSS files..." + echo "Minifying JS, CSS and SVG files..." - uglifyjs ${ROOT_DIR}/public/static/js/mapguesser.js -c -m -o ${ROOT_DIR}/public/static/js/mapguesser.js - cleancss ${ROOT_DIR}/public/static/css/mapguesser.css -o ${ROOT_DIR}/public/static/css/mapguesser.css + ${ROOT_DIR}/scripts/minify.sh fi From 334038dc974c90e9831bb76be89dd6e1cef813fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Sun, 24 May 2020 15:43:22 +0200 Subject: [PATCH 2/2] MAPG-62 add html-minifier to Dockerfile --- docker/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 1d55371..9e02cc7 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -23,8 +23,7 @@ RUN ./install-composer.sh # Install Node.js and required packages RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - RUN apt install -y nodejs -RUN npm install -g uglify-js -RUN npm install -g clean-css-cli +RUN npm install -g uglify-js clean-css-cli html-minifier EXPOSE 80 VOLUME /var/www/mapguesser