d9ea2e2254394dff8eea7fba016132c07d684894
[dygraphs.git] / scripts / build.sh
1 #!/bin/bash
2 # This generates:
3 # - dist/dygraph.js
4 # - dist/dygraph.js.map
5 # - dist/dygraph.min.js
6 # - dist/dygraph.min.js.map
7 set -o errexit
8
9 mkdir -p dist
10
11 # Create dist/dygraph.js
12 browserify \
13 -v \
14 -t babelify \
15 -t [ envify --NODE_ENV development ] \
16 --debug \
17 --standalone Dygraph \
18 src/dygraph.js \
19 > dist/dygraph.tmp.js
20
21 # Create dist/dygraph.js.map
22 cat dist/dygraph.tmp.js | exorcist --base . dist/dygraph.js.map > dist/dygraph.js
23
24 # Create "production" bundle for minification
25 browserify \
26 -v \
27 -t babelify \
28 -t [ envify --NODE_ENV production ] \
29 --debug \
30 --standalone Dygraph \
31 src/dygraph.js \
32 > dist/dygraph.tmp.js
33
34 # Create dist/dygraph.tmp.js.map
35 cat dist/dygraph.tmp.js | exorcist --base . dist/dygraph.tmp.js.map > /dev/null
36
37 # Create dist/dygraph.js.min{,.map}
38 uglifyjs --compress --mangle \
39 --in-source-map dist/dygraph.tmp.js.map \
40 --source-map-include-sources \
41 --source-map dist/dygraph.min.js.map \
42 -o dist/dygraph.min.js \
43 dist/dygraph.tmp.js
44
45 # Copy to the old location
46 cp dist/dygraph.min.js dist/dygraph-combined.js
47
48 # Build GWT JAR
49 jar -cf dist/dygraph-gwt.jar -C gwt org
50
51 # Remove temp files.
52 rm dist/dygraph.tmp.js
53 rm dist/dygraph.tmp.js.map