2023-08-26 08:26:47 -04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
#
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2023-09-02 08:52:13 -04:00
|
|
|
cleanup () {
|
|
|
|
if [ -d ../tmp/src/pages/api ]; then
|
|
|
|
echo "🦔 > Moving Mock API files back"
|
|
|
|
mv ../tmp/src/pages/api src/pages
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
trap cleanup EXIT
|
|
|
|
|
2023-08-26 08:26:47 -04:00
|
|
|
echo "🦔 Frontend Production Build"
|
|
|
|
echo "🦔 > Clearing existing builds"
|
|
|
|
rm -rf dist/
|
|
|
|
|
|
|
|
echo "🦔 > Preparing files"
|
2023-09-02 08:52:13 -04:00
|
|
|
if [ ! -z "${NEXT_PUBLIC_USE_MOCK_API}" ]; then
|
|
|
|
echo "🦔 > Keeping Mock API because NEXT_PUBLIC_USE_MOCK_API is set"
|
|
|
|
if [ ! -d src/pages/api ]; then
|
|
|
|
echo "🦔 > ⚠️ src/pages/api doesn't exist"
|
|
|
|
fi
|
2023-08-26 08:26:47 -04:00
|
|
|
else
|
2023-09-02 08:52:13 -04:00
|
|
|
echo "🦔 > Moving Mock API because NEXT_PUBLIC_USE_MOCK_API is unset"
|
|
|
|
mkdir -p ../tmp/src/pages
|
|
|
|
mv src/pages/api ../tmp/src/pages/api
|
2023-08-26 08:26:47 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "🦔 > Building"
|
2023-05-29 11:32:44 -04:00
|
|
|
BUILD_TIME=true next build
|
2023-08-26 08:26:47 -04:00
|
|
|
|
|
|
|
echo "🦔 > Bundling"
|
|
|
|
mv .next/standalone dist
|
|
|
|
mkdir -p dist/frontend/.next
|
|
|
|
cp -R .next/static dist/frontend/.next/static
|
|
|
|
cp next.config.js dist/frontend/next.config.js
|
|
|
|
cp -R public dist/frontend/public
|
|
|
|
rm -f dist/frontend/.env
|
|
|
|
rm -rf dist/frontend/public/public
|
|
|
|
rm -rf dist/frontend/src
|
|
|
|
|
|
|
|
echo "🦔 > Done! You can run the build by going into the dist directory and executing \`node frontend/server.js\`"
|