Add build configuration for VSCode and frontend build script

This commit is contained in:
Mikko Ahlroth 2020-04-03 20:52:13 +03:00
parent 6de89833bd
commit 7d41addfdf
3 changed files with 49 additions and 0 deletions

25
.vscode/tasks.json vendored Normal file
View file

@ -0,0 +1,25 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build with script",
"type": "shell",
"command": "./build.sh",
"presentation": {
"reveal": "always"
},
"options": {
"cwd": "./frontend",
"env": {
"SERVER_PATH": "http://localhost:1971/live"
}
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

1
frontend/.gitignore vendored
View file

@ -1,2 +1,3 @@
node_modules
build
dist.tgz

23
frontend/build.sh Executable file
View file

@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -eux
set -o pipefail
case "$OSTYPE" in
darwin*) PLATFORM="OSX" ;;
linux*) PLATFORM="LINUX" ;;
bsd*) PLATFORM="BSD" ;;
*) PLATFORM="UNKNOWN" ;;
esac
replace() {
if [[ "${PLATFORM}" == "OSX" || "${PLATFORM}" == "BSD" ]]; then
sed -i "" "$1" "$2"
elif [ "${PLATFORM}" == "LINUX" ]; then
sed -i "$1" "$2"
fi
}
tsc
replace "s#<%= SERVER_PATH %>#${SERVER_PATH}#g" build/*.js
tar -czvf dist.tgz index.html assets/ build/