mapcomplete/scripts/build.sh

62 lines
1.4 KiB
Bash
Raw Normal View History

#! /usr/bin/env bash
2022-01-08 19:15:56 +01:00
echo "Starting build"
# The build script; we build the application step by step as building everything at once takes too much RAM
# Should be run from the repository root
2022-01-08 19:15:56 +01:00
# This is the main deployment script
rm -rf dist/*
rm -rf .cache
mkdir dist 2> /dev/null
2021-12-22 02:10:02 +01:00
mkdir dist/assets 2> /dev/null
2023-02-10 15:02:43 +01:00
export NODE_OPTIONS="--max-old-space-size=8192"
2022-01-08 22:11:24 +01:00
# This script ends every line with '&&' to chain everything. A failure will thus stop the build
2022-07-06 16:35:14 +02:00
npm run generate:editor-layer-index &&
2022-01-08 22:11:24 +01:00
npm run generate &&
2022-07-18 15:15:48 +02:00
npm run generate:translations &&
2022-01-08 22:11:24 +01:00
npm run test &&
2022-10-28 04:03:34 +02:00
npm run generate:layeroverview &&
npm run generate:layouts
2022-01-11 10:55:17 +01:00
if [ $? -ne 0 ]; then
echo "ERROR - stopping the build"
2022-01-08 22:11:24 +01:00
exit 1
fi
2022-01-08 19:15:56 +01:00
2023-01-17 03:37:26 +01:00
SRC_MAPS=""
BRANCH=`git rev-parse --abbrev-ref HEAD`
echo "The branch name is $BRANCH"
if [ $BRANCH = "develop" ]
then
SRC_MAPS="--sourcemap"
echo "Source maps are enabled"
fi
2023-01-29 17:43:38 +01:00
if [ $BRANCH = "master" ]
then
ASSET_URL="./"
export ASSET_URL
echo "$ASSET_URL"
else
ASSET_URL="mc/$BRANCH"
export ASSET_URL
echo "$ASSET_URL"
fi
export NODE_OPTIONS=--max-old-space-size=6500
2023-01-17 03:37:26 +01:00
vite build $SRC_MAPS
# Copy the layer files, as these might contain assets (e.g. svgs)
cp -r assets/layers/ dist/assets/layers/
cp -r assets/themes/ dist/assets/themes/
cp -r assets/svg/ dist/assets/svg/
2022-06-20 10:59:23 +02:00
cp -r assets/tagRenderings/ dist/assets/tagRenderings/
cp assets/*.png dist/assets/
cp assets/*.svg dist/assets/
2023-02-16 18:18:40 +01:00
export NODE_OPTIONS=""