forked from mrsone40/vets-website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·71 lines (62 loc) · 1.75 KB
/
build.sh
File metadata and controls
executable file
·71 lines (62 loc) · 1.75 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh
##
# Run the application and content builds.
###
assetSource="local"
buildtype="localhost"
# Save the arguments to this script for later; they get drained in the following for loop
args="$*"
# Prepend "--env" to all args so they get passed to the Webpack config
webpackArgs=$(echo "${args}" | sed -E 's/--([^ =]+)/--env \1/g')
# Get options
for o in "$@"; do
case "${o}" in
--asset-source)
assetSource="$2"
shift # past "--asset-source"
shift # past value
;;
--asset-source=*)
assetSource="${o#*=}" # grab the value
shift # past the --asset-source=value
;;
--buildtype)
buildtype="$2"
shift
shift
;;
--buildtype=*)
buildtype="${o#*=}"
shift
;;
--destination)
destination="$2"
shift
shift
;;
--destination=*)
destination="${o#*=}"
shift
;;
*)
;;
esac
done
# If destination flag is absent, use buildtype as destination
destination="${destination:-$buildtype}"
echo "assetSource: ${assetSource}"
echo "buildtype: ${buildtype}"
echo "destination: ${destination}"
buildDir="$(dirname "$0")/../build/${destination}/"
if [ -d "${buildDir}" ]; then
echo "Removing build/${destination}"
rm -r "${buildDir}"
fi
# Only run Webpack if the assetSource = local
if [ "${assetSource}" = "local" ]; then
echo "Building application assets"
yarn build:webpack $webpackArgs
cp -v "${buildDir}generated/vendor.entry.js" "${buildDir}generated/shared-modules.entry.js"
else
echo "Will fetch application assets from the content build script"
fi