-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathbuild.sh
executable file
·40 lines (34 loc) · 1013 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
#!/bin/bash
set -e
sedi () {
sed --version >/dev/null 2>&1 && sed -i -- "$@" || sed -i "" "$@"
}
ARGS=$@
if [[ ${ARGS[*]} =~ 'feed' ]]; then
echo "Building feed and algolia index..."
# Fuck node.js seriously
sedi 's/ "type": "commonjs",/ "type": "module",/' package.json
ENABLE_GITHUB_READ=false yarn feed
ENABLE_GITHUB_READ=false yarn algolia
sedi 's/ "type": "module",/ "type": "commonjs",/' package.json
echo "Done building feed and algolia index..."
fi
if [[ ${ARGS[*]} =~ 'next' ]]; then
echo "Building Next.js..."
ENABLE_GITHUB_READ=false yarn next build
echo "Done building Next.js..."
fi
if [[ ${ARGS[*]} =~ 'public' ]]; then
echo "Building public..."
# compress public JS files
shopt -s nullglob
FILES="./public/*.js"
for f in $FILES
do
if !(echo "$f" | grep -q "\.min\.js$"); then
NAME=`echo "$f" | sed -e 's/\(.*\)\.js$/\1\.min\.js/'`
yarn terser --config-file terser.config.json -o $NAME $f
fi
done
echo "Done building public..."
fi