forked from alexwforsythe/code-blocks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·57 lines (48 loc) · 1.35 KB
/
build.sh
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
set -e
dist_dir="dist"
mkdir -p ${dist_dir}
gas () {
cp appsscript.json ${dist_dir}
cp server/*.js ${dist_dir}
}
js () {
# wrap bundled js in script tags and rename as html
input_file="client/sidebar.js"
output_file="${dist_dir}/bundle.min.js.html"
echo "<script>" > ${output_file}
browserify -t 'uglifyify' ${input_file} | uglifyjs >> ${output_file}
echo "</script>" >> ${output_file}
}
html () {
cp client/*.html ${dist_dir}
}
css () {
output_file="${dist_dir}/styles.html"
optimizations="optimizeBackground:off;"
optimizations+="replaceMultipleZeros:off;"
optimizations+="specialComments:off"
# wrap all theme css in style tags and bundle into html
echo "<html>" > ${output_file}
for filename in node_modules/highlight.js/styles/*.css; do
theme_name=$(basename ${filename} .css)
if [[ ${theme_name} != 'darkula' ]]; then
theme="<style id=\"${theme_name}\">"
theme+=$(cleancss --debug -O1 ${optimizations} ${filename})
theme+="</style>"
echo ${theme} >> ${output_file}
fi
done
echo "</html>" >> ${output_file}
}
case "$1" in
"gas") gas;;
"js") js;;
"html") html;;
"css") css;;
"static") html && css;;
*)
echo "invalid command: $1"
exit 1
;;
esac