-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·63 lines (51 loc) · 1.17 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#! /bin/bash
set -eu
TRAVIS_BLOG_TOKEN=${DEPLOY_BLOG_TOKEN:-''}
if [ -z $TRAVIS_BLOG_TOKEN ]
then
DEPLOY_REPO="[email protected]:pauldambra/blog_source.git"
else
DEPLOY_REPO="https://${TRAVIS_BLOG_TOKEN}@github.com/pauldambra/pauldambra.github.io.git"
fi
function main {
clean
get_current_site
update_service_worker
build_site
# minify_site
}
function clean {
echo "cleaning _site folder"
if [ -d "_site" ]; then rm -Rf _site; fi
}
function get_current_site {
echo "getting latest site"
git clone --progress --depth 1 $DEPLOY_REPO _site
}
function update_service_worker {
echo "updating service worker"
npm install sw-precache
./node_modules/.bin/sw-precache --config service-worker-config.js
}
function build_site {
echo "building site"
bundle exec jekyll build
}
# ugh this breaks the build!
function minify_site {
npm install html-minifier
./node_modules/.bin/html-minifier \
--html5 \
--case-sensitive \
--keep-closing-slash \
--collapse-inline-tag-whitespace \
--collapse-whitespace \
--minify-css \
--minify-js \
--input-dir _site \
--output-dir _site2 \
--file-ext html
rm -rf _site/
mv _site2 _site
}
main