From 2d2eba3ef6aa4b53404fbf5e06eb1757deeafaf5 Mon Sep 17 00:00:00 2001 From: Carlo Alberto Ferraris Date: Mon, 1 Mar 2021 14:21:17 +0000 Subject: [PATCH] wip: css minification --- Dockerfile.builder | 2 +- compress.sh | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Dockerfile.builder b/Dockerfile.builder index 596fe40..5fced20 100644 --- a/Dockerfile.builder +++ b/Dockerfile.builder @@ -32,7 +32,7 @@ RUN git clone --depth 1 https://github.com/AOMediaCodec/libavif.git && \ cd /usr/local/bin && \ ln -s /libavif/build/avifenc -RUN npm install -g svgo uglify-js +RUN npm install -g svgo uglify-js clean-css-cli COPY cmd/alt_path /cmd/alt_path RUN (cd /cmd/alt_path && go get && go build -o /usr/local/bin/alt_path) diff --git a/compress.sh b/compress.sh index 394052e..fa586d1 100755 --- a/compress.sh +++ b/compress.sh @@ -164,6 +164,13 @@ JS_FILES=$( -printf '%P\n' \ ) +CSS_FILES=$( + find . -type f \ + -iname '*.css' \ + -size +1 \ + -printf '%P\n' \ +) + COMPRESSIBLE_FILES=$( find . -type f \ -not -iname '*.gif' \ @@ -308,6 +315,15 @@ minify_js() { FILE=$1 foreach "$JS_FILES" minify_js +## minify css files + +minify_css() { FILE=$1 + cleancss -o "$FILE.cleancss" -- "$FILE" || rm -f "$FILE.cleancss" + mv -f "$FILE.cleancss" "$FILE" +} + +foreach "$CSS_FILES" minify_css + ## precompress uncompressed files wait # some files that we need to compress may still be being worked on