2021-01-29 19:48:27 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
wdir=$(readlink -e "$(dirname "$0")/..")
|
|
|
|
|
|
|
|
version=$(cat "$wdir/version.sbt" | cut -d'=' -f2 | sed 's,[" ],,g')
|
|
|
|
targetbase="$wdir/modules/webapp/target/scala-2.13/classes/META-INF/resources/webjars/docspell-webapp/$version"
|
|
|
|
resourcebase="$wdir/modules/webapp/target/scala-2.13/resource_managed/main/META-INF/resources/webjars/docspell-webapp/$version"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
compile_js() {
|
|
|
|
echo "Compile elm to js …"
|
|
|
|
local srcs="$wdir/modules/webapp/src/main/elm/Main.elm"
|
|
|
|
elm make --debug --output "$targetbase/docspell-app.js" "$srcs"
|
|
|
|
cat "$targetbase/docspell-app.js" | gzip > "$targetbase/docspell-app.js.gz"
|
|
|
|
cp "$targetbase/docspell-app.js" "$resourcebase/"
|
|
|
|
cp "$targetbase/docspell-app.js.gz" "$resourcebase/"
|
|
|
|
}
|
|
|
|
|
|
|
|
compile_css() {
|
|
|
|
echo "Building css …"
|
|
|
|
local srcs="$wdir/modules/webapp/src/main/styles/index.css"
|
|
|
|
local target="$targetbase/css/styles.css"
|
2024-03-10 19:13:41 +00:00
|
|
|
cd $wdir/modules/webapp && tailwindcss --input "$srcs" -o "$target" --config ./tailwind.config.js --postcss ./postcss.config.js --env development && cd -
|
2021-01-29 19:48:27 +00:00
|
|
|
cat "$target" | gzip > "$targetbase/css/styles.css.gz"
|
|
|
|
cp "$targetbase/css/styles.css" "$resourcebase/css/"
|
|
|
|
cp "$targetbase/css/styles.css.gz" "$resourcebase/css/"
|
|
|
|
}
|
|
|
|
|
2021-12-20 22:03:05 +00:00
|
|
|
watch_js() {
|
|
|
|
echo "Watching for elm sources. C-c to quit."
|
|
|
|
inotifywait -r --format '%w%f' \
|
|
|
|
-e close_write -m \
|
|
|
|
"$wdir/modules/webapp/src/main/elm" |
|
|
|
|
while read pathfile; do
|
|
|
|
compile_js
|
|
|
|
echo "Done."
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
watch_css() {
|
|
|
|
echo "Watching css …"
|
|
|
|
rm -f "$targetbase/css"/*.css
|
|
|
|
rm -f "$resourcebase/css"/*.css
|
|
|
|
local srcs="$wdir/modules/webapp/src/main/styles/index.css"
|
|
|
|
local target="$targetbase/css/styles.css"
|
|
|
|
cd $wdir/modules/webapp && \
|
2024-03-10 19:13:41 +00:00
|
|
|
tailwindcss --input "$srcs" \
|
2021-12-20 22:03:05 +00:00
|
|
|
-o "$target" -m \
|
|
|
|
--config ./tailwind.config.js \
|
|
|
|
--postcss ./postcss.config.js --watch
|
|
|
|
}
|
2021-01-29 19:48:27 +00:00
|
|
|
|
|
|
|
watch_both() {
|
|
|
|
echo "Watching css and elm sources. C-c to quit."
|
|
|
|
inotifywait -r --format '%w%f' \
|
|
|
|
-e close_write -m \
|
|
|
|
"$wdir/modules/webapp/src/main/elm" \
|
|
|
|
"$wdir/modules/webapp/src/main/styles/" |
|
|
|
|
while read pathfile; do
|
|
|
|
if [[ "$pathfile" == *".elm" ]]; then
|
|
|
|
compile_js
|
2021-12-20 22:03:05 +00:00
|
|
|
compile_css
|
2021-01-29 19:48:27 +00:00
|
|
|
echo "Done."
|
|
|
|
elif [[ "$pathfile" == *".css" ]]; then
|
|
|
|
compile_css
|
|
|
|
echo "Done."
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-06-26 12:43:16 +00:00
|
|
|
cd "$wdir/modules/webapp"
|
2021-12-20 22:03:05 +00:00
|
|
|
arg=${1:-_}
|
|
|
|
case "$arg" in
|
2021-01-29 19:48:27 +00:00
|
|
|
all)
|
|
|
|
compile_js
|
|
|
|
compile_css
|
|
|
|
echo "Done."
|
|
|
|
;;
|
|
|
|
|
|
|
|
js)
|
|
|
|
compile_js
|
|
|
|
echo "Done."
|
|
|
|
;;
|
|
|
|
|
|
|
|
css)
|
|
|
|
compile_css
|
|
|
|
echo "Done."
|
|
|
|
;;
|
|
|
|
|
2021-12-20 22:03:05 +00:00
|
|
|
watch-js)
|
2021-01-29 19:48:27 +00:00
|
|
|
set +e
|
|
|
|
compile_js
|
2021-12-20 22:03:05 +00:00
|
|
|
watch_js
|
|
|
|
;;
|
|
|
|
|
|
|
|
watch-css)
|
|
|
|
set +e
|
|
|
|
watch_css
|
2021-01-29 19:48:27 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
2021-12-20 22:03:05 +00:00
|
|
|
echo "Need one of: all, js, css, watch, watch-js, watch-css"
|
2021-01-29 19:48:27 +00:00
|
|
|
exit 1
|
|
|
|
esac
|