From 7d41addfdfb4b61db29d33ce0a5c672ae152a4ad Mon Sep 17 00:00:00 2001 From: Mikko Ahlroth Date: Fri, 3 Apr 2020 20:52:13 +0300 Subject: [PATCH] Add build configuration for VSCode and frontend build script --- .vscode/tasks.json | 25 +++++++++++++++++++++++++ frontend/.gitignore | 1 + frontend/build.sh | 23 +++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 .vscode/tasks.json create mode 100755 frontend/build.sh diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..9bb973d --- /dev/null +++ b/.vscode/tasks.json @@ -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 + } + } + ] +} diff --git a/frontend/.gitignore b/frontend/.gitignore index dd87e2d..0b77489 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -1,2 +1,3 @@ node_modules build +dist.tgz diff --git a/frontend/build.sh b/frontend/build.sh new file mode 100755 index 0000000..76b46cc --- /dev/null +++ b/frontend/build.sh @@ -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/