Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml36
-rwxr-xr-xscripts/minify-assets.sh9
2 files changed, 15 insertions, 30 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 2bb56369..95c747cd 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -94,6 +94,7 @@ variables:
###############################################
.build_base:
+ image: registry.gitlab.com/gitlab-org/gitlab-docs:bootstrap
stage: build
extends:
- .cache_gem_yarn
@@ -105,9 +106,16 @@ variables:
# Symlink all README.html to index.html so that we can have clean URLs
- for i in `find public -name README.html`; do ln -sf README.html $(dirname $i)/index.html; done
# Remove CE dir and symlink EE to CE
- - if [ $CI_PIPELINE_SOURCE != 'pipeline' ]; then cd public && rm -rf ce && ln -s ee ce; fi
+ - if [ $CI_PIPELINE_SOURCE != 'pipeline' ]; then cd public && rm -rf ce && ln -s ee ce && cd ../; fi
# Use gzip to compress content
- - find . -type f \( -iname "*.html" -o -iname "*.js" -o -iname "*.css" -o -iname "*.svg" \) -exec gzip --keep --best --force --verbose {} \;
+ - SIZE_BEFORE_GZIP=$(du -sh public/)
+ - find public/ -type f \( -iname "*.html" -o -iname "*.js" -o -iname "*.css" -o -iname "*.svg" \) -exec gzip --keep --best --force --verbose {} \;
+ - SIZE_AFTER_GZIP=$(du -sh public/)
+ # Minify the assets of the resulting site
+ - ./scripts/minify-assets.sh ./ public/
+ - SIZE_AFTER_MINIFY=$(du -sh public/)
+ # Print size results
+ - echo -e "Size before gzipping $SIZE_BEFORE_GZIP\nSize after gzipping $SIZE_AFTER_GZIP\nSize after minifying $SIZE_AFTER_MINIFY"
artifacts:
paths:
- public
@@ -315,30 +323,6 @@ pages:
# the image we pull from.
#
- mv /usr/share/nginx/html/1* public/
-
- #
- # Check the size before minifying
- #
- - du -sh public/
-
- #
- # Minify the assets of the resulting site. The single versions
- # will be minified eventually when the minification propagates
- # to all versions that are included in gitlab-docs:latest
- # (around 12.7), but we also need to minify the content we
- # pull from master. Currently, there's no way to exclude
- # files or directories when minifying, so we minify the whole
- # site (even the versions that are already minified).
- # TODO: Move to top.
- # When all versions are minified, we can move this script
- # to run first and avoid minifying the already minified versions.
- #
- - /scripts/minify-assets.sh ./ public/
-
- #
- # Check the size after minifying
- #
- - du -sh public/
artifacts:
paths:
- public
diff --git a/scripts/minify-assets.sh b/scripts/minify-assets.sh
index 02562039..a0b5bfb7 100755
--- a/scripts/minify-assets.sh
+++ b/scripts/minify-assets.sh
@@ -2,6 +2,7 @@
TARGET="$1"
VER="$2"
+MINIFY_FLAGS="--html-keep-document-tags --html-keep-whitespace --recursive"
if [ -z "$TARGET" -o -z "$VER" ]; then
echo "Usage: $0 <target> <ver>"
@@ -17,9 +18,9 @@ fi
# Minify assets
printf "Optimizing assets..."
-printf "HTML..."; /scripts/minify -r --type=html --match=\.html -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true
-printf "CSS..." ; /scripts/minify -r --type=css --match=\.css -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true
-printf "JSON..."; /scripts/minify -r --type=json --match=\.json -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true
-printf "SVG..." ; /scripts/minify -r --type=svg --match=\.svg -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true
+printf "HTML..."; /scripts/minify $MINIFY_FLAGS --type=html --match=\.html -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true
+printf "CSS..." ; /scripts/minify $MINIFY_FLAGS --type=css --match=\.css -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true
+printf "JSON..."; /scripts/minify $MINIFY_FLAGS --type=json --match=\.json -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true
+printf "SVG..." ; /scripts/minify $MINIFY_FLAGS --type=svg --match=\.svg -o ${TARGET}/${VER}/ ${TARGET}/${VER} || true
echo "Done"