67 lines
1.2 KiB
Bash
67 lines
1.2 KiB
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
|
||
|
|
line_sep="==============================="
|
||
|
|
|
||
|
|
cur_dir="$(cd "$( dirname "$0")" && pwd)"
|
||
|
|
cur_dir="$(cd $(dirname "$cur_dir") && pwd)"
|
||
|
|
|
||
|
|
run_npm_install=false
|
||
|
|
|
||
|
|
show_help() {
|
||
|
|
echo "Frontend Webpack Builder
|
||
|
|
The script for building the frontend webpack to be used by the web app.
|
||
|
|
|
||
|
|
Usage: build_frontend_webpack.sh [options]
|
||
|
|
|
||
|
|
Options:
|
||
|
|
-i|--npm-install: Runs an npm install before building the webpack.
|
||
|
|
-h|--help: Shows this help message.
|
||
|
|
"
|
||
|
|
}
|
||
|
|
|
||
|
|
while [[ "$#" -gt 0 ]]; do
|
||
|
|
case "$1" in
|
||
|
|
-i|--npm-install)
|
||
|
|
run_npm_install=true
|
||
|
|
shift 1
|
||
|
|
;;
|
||
|
|
-h|--help)
|
||
|
|
show_help
|
||
|
|
exit
|
||
|
|
;;
|
||
|
|
*)
|
||
|
|
echo "Invalid argument given ($1)"
|
||
|
|
exit 1
|
||
|
|
;;
|
||
|
|
esac
|
||
|
|
done
|
||
|
|
|
||
|
|
echo "Building frontend webpack in $cur_dir/UI"
|
||
|
|
|
||
|
|
# Run from the UI directory
|
||
|
|
cd "$cur_dir/UI" || (echo "UI directory does not exist" && exit 1)
|
||
|
|
|
||
|
|
if "$run_npm_install"; then
|
||
|
|
echo "$line_sep"
|
||
|
|
echo "Running NPM install"
|
||
|
|
echo "$line_sep"
|
||
|
|
|
||
|
|
npm install
|
||
|
|
|
||
|
|
echo "$line_sep"
|
||
|
|
echo "NPM install complete"
|
||
|
|
echo "$line_sep"
|
||
|
|
fi
|
||
|
|
echo "$line_sep
|
||
|
|
Running NPM build
|
||
|
|
$line_sep"
|
||
|
|
# run the NPM build now
|
||
|
|
npm run build --production
|
||
|
|
echo "$line_sep
|
||
|
|
NPM build complete
|
||
|
|
$line_sep"
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|