forked from yihui/yihui.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·45 lines (36 loc) · 922 Bytes
/
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
#!/bin/sh
cd static
# clone js/css from a few other repos
ALL_REPOS="misc.js arith.js zdict.js"
for i in $ALL_REPOS; do
git clone --depth=1 https://github.com/yihui/$i.git
done
# zdict.js needs a custom build
cd zdict.js
./build.sh
cd ..
for i in $ALL_REPOS; do
[ -d $i/js ] && cp $i/js/*.js js/
[ -d $i/css ] && cp $i/css/*.css css/
rm -rf $i
done
# minify css
npm install clean-css-cli -g
cleancss --batch --batch-suffix '.min' css/*.css
# minify js
npm install terser -g
for i in js/*.js; do
terser $i --compress --mangle --source-map --output ${i%.js}.min.js
done
# do not index the site on Netlify (only index the one built on Vercel)
if [ "$NETLIFY" = "true" ]; then
echo 'User-agent: *
Disallow: /' > robots.txt
fi
cd ..
# Netlify uses $CONTEXT and Vercel uses $VERCEL_ENV
if [ "${VERCEL_ENV:-$CONTEXT}" = "production" ]; then
hugo -F
else
hugo -F -D -b ${VERCEL_URL:-$DEPLOY_PRIME_URL}
fi