1 | #!/usr/bin/env bash
|
2 |
|
3 | set -e
|
4 |
|
5 | package=$1
|
6 | standalone=$2
|
7 | compress=$3
|
8 |
|
9 | name=$(./scripts/info $package name)
|
10 | main=$(./scripts/info $package main)
|
11 | version=$(./scripts/info $package version)
|
12 | description=$(./scripts/info $package description)
|
13 |
|
14 | if [ "$package" != "." ]; then
|
15 | package="./node_modules/$package"
|
16 | fi
|
17 |
|
18 | mkdir -p dist
|
19 |
|
20 | browserify -r "$package/$main:$name" \
|
21 | -o "dist/$name.bundle.js" \
|
22 | $([ -n "$standalone" ] && echo "-s $standalone")
|
23 |
|
24 | uglifyjs dist/$name.bundle.js \
|
25 | -o dist/$name.min.js \
|
26 | -c $compress \
|
27 | -m \
|
28 | $([ -n "$standalone" ] && echo "--source-map dist/$name.min.js.map -r $standalone") \
|
29 | --preamble "/* $name $version: $description */"
|
30 |
|
31 | if [ -z "$standalone" ]; then
|
32 | rm dist/$name.bundle.js
|
33 | fi
|