New build mechanism
This commit is contained in:
parent
fa4bf3e6dc
commit
4e0216a895
1
frontend/.gitignore
vendored
1
frontend/.gitignore
vendored
@ -10,3 +10,4 @@ repl-temp-*
|
||||
|
||||
# End of https://www.gitignore.io/api/elm
|
||||
index.html
|
||||
output
|
||||
|
39
frontend/build.sh
Executable file
39
frontend/build.sh
Executable file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
js="gitcdn.js"
|
||||
min="gitcdn.min.js"
|
||||
outdir="./output/"
|
||||
scriptdir="${outdir}scripts/"
|
||||
|
||||
prepare() {
|
||||
mkdir -p "${outdir}/scripts"
|
||||
}
|
||||
|
||||
build() {
|
||||
elm make --optimize src/Main.elm --output=${js}
|
||||
}
|
||||
|
||||
minify() {
|
||||
uglifyjs ${js} --compress 'pure_funcs="F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9",pure_getters,keep_fargs=false,unsafe_comps,unsafe' | uglifyjs --mangle --output=${min}
|
||||
}
|
||||
|
||||
sha1() {
|
||||
sha1sum ${min} | cut -d' ' -f 1
|
||||
}
|
||||
|
||||
rename_with_hash() {
|
||||
sha1=${1}
|
||||
cp ${min} "${scriptdir}/gitcdn-${sha1}.min.js"
|
||||
}
|
||||
|
||||
create_index() {
|
||||
sha1=${1}
|
||||
SHA1="${sha1}" envsubst < index.html > "${outdir}/index.html"
|
||||
}
|
||||
|
||||
prepare
|
||||
build
|
||||
minify
|
||||
sha1=$(sha1)
|
||||
rename_with_hash "${sha1}"
|
||||
create_index "${sha1}"
|
Loading…
Reference in New Issue
Block a user