-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·34 lines (24 loc) · 835 Bytes
/
Copy pathbuild.sh
File metadata and controls
executable file
·34 lines (24 loc) · 835 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
34
#!/usr/bin/env bash -ex
npm i
# Directories.
SRC=src
DIST=dist
TEMP=dist-temp
# Commands.
BROWSERIFY=./node_modules/browserify/bin/cmd.js
UGLIFY=./node_modules/uglify-js/bin/uglifyjs
rm -rf $DIST
mkdir $DIST
rm -rf $TEMP
mkdir $TEMP
# Bundle the jsonwebtoken module and its dependencies.
$BROWSERIFY $SRC/main.js --standalone jwt > $TEMP/main.bundle.js
# Wrap the bundle in its own named callable scope.
cat $SRC/main-prefix.txt $TEMP/main.bundle.js $SRC/main-suffix.txt > $TEMP/main.bundle.wrapped.js
# Minify.
$UGLIFY --compress --mangle -- $TEMP/main.bundle.wrapped.js > $TEMP/main.bundle.wrapped.min.js
# Make a file that has an extra space in it.
touch $TEMP/space.txt
echo >> $TEMP/space.txt
# Prepend the setup code.
cat $SRC/preamble.txt $TEMP/space.txt $TEMP/main.bundle.wrapped.min.js > $DIST/pre-request-script.js