Yzena
/
Yc
2
1
Fork 0
Yzena's monorepo. Includes Yvm, Yao, Rig, Ur, and Yar. https://docs.yzena.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
1.6 KiB

#! /bin/bash
#
# ***** BEGIN LICENSE BLOCK *****
#
# Copyright 2017-2022 Yzena Tech
#
# Licensed under the Yzena Network License, Version 0.1 (the "Yzena Network
# License" or "YNL"). You may not use this file except in compliance with the
# Yzena Network License.
#
# You may obtain a copy of the Yzena Network License at
#
# https://yzena.com/yzena-network-license/
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the Yzena Network License is distributed under the
# following disclaimer:
#
# As far as the law allows, this software comes as is, without any
# warranty or condition, and no contributor will be liable to anyone for
# any damages related to this software or this license, under any kind of
# legal claim.
#
# ****** END LICENSE BLOCK ******
#
usage() {
printf 'usage: %s <build_directory> <docs_directory>\n' "$0"
exit 1
}
compress() {
f="$1"
zopfli "$f" --stdout > "$f.gz"
}
export -f compress
set -e
script="$0"
scriptdir=$(dirname "$script")
if [ "$#" -ge 1 ]; then
build_dir="$1"
shift
else
usage
fi
if [ "$#" -ge 1 ]; then
docs_dir="$1"
shift
else
usage
fi
if [ -f "$scriptdir/../purgecss.config.js" ]; then
printf '\nPurging CSS...'
cp "$scriptdir/../purgecss.config.js" "$docs_dir"
npx purgecss -c "purgecss.config.js" -o "$build_dir/_static"
printf 'Done\n'
fi
exts="html
css
js
ttf
woff2
atom
stl
xml
svg
eot
ico
gaml
json"
s=""
for t in $exts; do
temp=$(find $build_dir -type f -name "*.$t")
if [ "$temp" != "" ]; then
s=$(printf '%s\n%s' "$temp" "$s")
fi
done
printf '%s\n' "$s" | parallel --progress --eta -j$CORES compress