summaryrefslogtreecommitdiff
path: root/deploy/build_js.sh
blob: b1019f7a958bba47e35003d2dc7dfeee7129b770 (plain)
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
#!/bin/bash

PROGNAME="$0"
DIR="$( cd "$( dirname "$(readlink -f "${BASH_SOURCE[0]}")" )" && pwd )"

. $DIR/build_common.sh

# suckless version of webpack
# watch and learn, bitches!
build_chunk() {
    local name="$1"
    local output="$OUTDIR/$name.js"
    local not_first=0
    for file in "$INDIR/$name"/*.js; do
        # insert newline before out comment
        [ "$not_first" = "1" ] && echo "" >> "$output"
        echo "/* $(basename "$file") */" >> "$output"

        cat "$file" >> "$output"
        not_first=1
    done
}

TARGETS="common admin"

input_args "$@"
check_args

for f in $TARGETS; do
    build_chunk "$f"
done