revert change to demo.html from 1.1.1
[dygraphs.git] / scripts / build.sh
1 #!/bin/bash
2 # This generates everything under dist:
3 # bundled JS, minified JS, minified CSS and source maps.
4 set -o errexit
5
6 mkdir -p dist
7
8 # Create dist/dygraph.js
9 browserify \
10 -v \
11 -t babelify \
12 -t [ envify --NODE_ENV development ] \
13 --debug \
14 --standalone Dygraph \
15 src/dygraph.js \
16 > dist/dygraph.tmp.js
17
18 # Create dist/dygraph.js.map
19 cat dist/dygraph.tmp.js | exorcist --base . dist/dygraph.js.map > dist/dygraph.js
20
21 # Create "production" bundle for minification
22 browserify \
23 -v \
24 -t babelify \
25 -t [ envify --NODE_ENV production ] \
26 --debug \
27 --standalone Dygraph \
28 src/dygraph.js \
29 > dist/dygraph.tmp.js
30
31 # Create dist/dygraph.tmp.js.map
32 cat dist/dygraph.tmp.js | exorcist --base . dist/dygraph.tmp.js.map > /dev/null
33
34 header='/*! @license Copyright 2017 Dan Vanderkam (danvdk@gmail.com) MIT-licensed (http://opensource.org/licenses/MIT) */'
35
36 # Create dist/dygraph.js.min{,.map}
37 uglifyjs --compress --mangle \
38 --preamble "$header" \
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 # Build GWT JAR
46 jar -cf dist/dygraph-gwt.jar -C gwt org
47
48 # Minify CSS
49 cp css/dygraph.css dist/
50 cleancss css/dygraph.css -o dist/dygraph.min.css --source-map --source-map-inline-sources
51
52 # Build ES5-compatible distribution
53 babel src -d src-es5 --compact false
54
55 # Remove temp files.
56 rm dist/dygraph.tmp.js
57 rm dist/dygraph.tmp.js.map