Browse Source

Add build files

master
Gavin Howard 11 months ago
parent
commit
da4af8fc6a
Signed by: gavin GPG Key ID: C08038BDF280D33E
  1. 65
      build.sh
  2. 7
      purgecss.config.js

65
build.sh

@ -0,0 +1,65 @@
#! /bin/bash
usage() {
printf 'usage: %s [--no-gzip]\n' "$0"
exit 0
}
compress() {
f="$1"
zopfli "$f" --stdout > "$f.gz"
}
export -f compress
set -e
script="$0"
scriptdir=$(dirname "$script")
gz=1
if [ "$#" -ge 1 ]; then
if [ "$1" = "--no-gzip" ]; then
gz=0
fi
fi
SITE_DIR="public"
exts="html
css
js
ttf
atom
stl
xml
svg
eot
ico
json"
rm -rf $SITE_DIR
hugo --minify --gc
printf '\nPurging CSS...'
npx purgecss -c "$scriptdir/purgecss.config.js" -o "$SITE_DIR/css"
printf 'Done\n'
sed -i -f "$scriptdir/script.sed" "$SITE_DIR/css/theme.css"
s=""
for t in $exts; do
temp=$(find $SITE_DIR -type f -name "*.$t")
if [ "$temp" != "" ]; then
s=$(printf '%s\n%s' "$temp" "$s")
fi
done
if [ "$gz" -ne 0 ]; then
printf '%s\n' "$s" | parallel --progress --eta -j$CORES compress
fi
rm -rf "$SITE_DIR/purgecss.config.js" "$SITE_DIR/LICENSE.txt" "$SITE_DIR/LICENSE" "$SITE_DIR/build.sh"

7
purgecss.config.js

@ -0,0 +1,7 @@
module.exports = {
content: [ 'public/**/*.html' ],
css: [ 'public/css/theme.css' ],
whitelist: [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', '::-webkit-scrollbar',
'::-webkit-scrollbar-thumb', '::-webkit-scrollbar-track',
'::-webkit-scrollbar-track-piece' ]
}
Loading…
Cancel
Save