-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·33 lines (30 loc) · 750 Bytes
/
Copy pathbuild.sh
File metadata and controls
executable file
·33 lines (30 loc) · 750 Bytes
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
#!/usr/bin/env bash
has_param() {
local term="$1"
shift
for arg; do
if [[ $arg == "$term" ]]; then return 0; fi
done
return 1
}
# First argument is filepath (or filename, without extension)
#
# Supported flags:
# --watch: Rebuild automatically when changes are detected
build() {
local file_path=$1
local name_override=$2
local file=$(basename $file_path)
if [[ -z $name_override ]]; then
local file_noext="${file%.*}"
else
local file_noext=$name_override
fi
local cmd
cmd="rollup --config rollup.config.ts --environment file_path:$file_path,file:$file_noext --configPlugin @rollup/plugin-typescript"
if has_param '--watch' "$@"; then cmd+=' --watch'; fi
$cmd
}
build_and_watch() {
build "$1" --watch
}