-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdist.sh
More file actions
executable file
·49 lines (40 loc) · 1.31 KB
/
dist.sh
File metadata and controls
executable file
·49 lines (40 loc) · 1.31 KB
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
#!/bin/sh
set -e
# Parse CLI arguments
BUILD_FUTURE=false
for arg in "$@"; do
if [ "$arg" = "--buildFuture" ]; then
BUILD_FUTURE=true
fi
done
# Check if VERCEL_ENV is preview or development
if [ "$VERCEL_ENV" = "preview" ] || [ "$VERCEL_ENV" = "development" ]; then
BUILD_FUTURE=true
fi
echo "\033[0;1mBuilding for environment: \033[0;1;35mproduction\033[0;0m"
echo "\033[0;1mHugo version\033[0;0m"
hugo version
# Remove old compiled data
echo "\033[0;1mCleaning destination directory...\033[0;0m"
rm -rf public
# Run "npm install" in the theme folder
# Then symlink node_modules so hugo can build the site
echo "\033[0;1mRefreshing theme dependencies...\033[0;0m"
(cd themes/withblueink && npm ci)
[ ! -e node_modules ] && ln -s -v themes/withblueink/node_modules
# Compile the code with the "production" environment
echo "\033[0;1mBuilding...\033[0;0m"
#hugo --environment=production --buildFuture
if [ "$BUILD_FUTURE" = true ]; then
hugo --environment=production --minify --buildFuture
else
hugo --environment=production --minify
fi
# Remove files that shouldn't be published
echo "\033[0;1mRemoving unnecessary files...\033[0;0m"
rm -v public/*.sh || true
rm -v public/.dockerignore || true
rm -v public/Makefile || true
rm -v public/Dockerfile || true
rm -rvf public/docker || true
rm -v public/**/.gitignore || true