Fix build-web-view

This commit is contained in:
MartinBraquet
2025-11-15 15:51:44 +01:00
parent f650ab7394
commit 37ee7752c2
4 changed files with 47 additions and 55 deletions

View File

@@ -76,7 +76,7 @@ javac -version
```
yarn install
yarn build-web
yarn build-web-view
```
### Local mode
@@ -110,7 +110,7 @@ cd android
Sync web files and native plugins with Android, for offline fallback. In root:
```
export NEXT_PUBLIC_LOCAL_ANDROID=1 # if running your local web Compass
yarn build-web # if you made changes to web app
yarn build-web-view # if you made changes to web app
npx cap sync android
```
@@ -247,7 +247,7 @@ yarn dev # or prod
# Terminal 2: start frontend
export NEXT_PUBLIC_LOCAL_ANDROID=1
yarn build-web # if you made changes to web app
yarn build-web-view # if you made changes to web app
npx cap sync android
# Run on emulator or device
```
@@ -275,7 +275,7 @@ npm install -g @capawesome/cli@latest
npx @capawesome/cli login
```
Then, run this to build your local assets and push them to Capawesome. Once done, each mobile app user will receive a notice that there is a new update available, which they can approve to download.
Then, run this to build your local assets and push them to Capawesome. Once done, each mobile app user will receive a notice that there is a new update available, which they can approve to download.
```
yarn build-web-view
npx @capawesome/cli apps:bundles:create --path web/out

View File

@@ -16,8 +16,7 @@
"dev": "./scripts/run_local.sh dev",
"prod": "./scripts/run_local.sh prod",
"clean-install": "./scripts/install.sh",
"build-web": "./scripts/build_web.sh",
"build-web-view": "./scripts/build_web.sh",
"build-web-view": "./scripts/build_web_view.sh",
"build-sync-android": "./scripts/build_sync_android.sh",
"sync-android": "./scripts/sync_android.sh",
"migrate": "./scripts/migrate.sh",

View File

@@ -1,48 +0,0 @@
#!/bin/bash
set -e
cd "$(dirname "$0")"/..
# Paths
ROOT_ENV=".env" # your root .env
WEB_ENV="web/.env" # target for frontend
# Backup existing web/.env if it exists
if [ -f "$WEB_ENV" ]; then
cp "$WEB_ENV" "${WEB_ENV}.bak"
echo "Backed up existing $WEB_ENV to ${WEB_ENV}.bak"
fi
# Filter NEXT_PUBLIC_* lines
grep '^NEXT_PUBLIC_' "$ROOT_ENV" > "$WEB_ENV"
echo "Copied NEXT_PUBLIC_ variables to $WEB_ENV:"
echo "NEXT_PUBLIC_FIREBASE_ENV=prod" >> "$WEB_ENV"
cat "$WEB_ENV"
cd web
rm -rf .next
# Hack to ignore getServerSideProps, getStaticProps and getStaticPaths for mobile webview build
# as Next.js doesn't support SSG, SSR and ISR on mobile
USERNAME_PAGE=pages/[username]/index.tsx
HOME_PAGE=pages/index.tsx
# rename getStaticProps to _getStaticProps
sed -i.bak 's/\bgetStaticProps\b/_getStaticProps/g' $USERNAME_PAGE
# rename getStaticPaths to _getStaticPaths
sed -i.bak 's/\bgetStaticPaths\b/_getStaticPaths/g' $USERNAME_PAGE
# rename getServerSideProps to _getServerSideProps
sed -i.bak 's/\bgetServerSideProps\b/_getServerSideProps/g' $HOME_PAGE
yarn build
sed -i.bak 's/\b_getStaticProps\b/getStaticProps/g' $USERNAME_PAGE
sed -i.bak 's/\b_getStaticPaths\b/getStaticPaths/g' $USERNAME_PAGE
sed -i.bak 's/\b_getServerSideProps\b/getServerSideProps/g' $HOME_PAGE

View File

@@ -6,4 +6,45 @@ cd "$(dirname "$0")"/..
export NEXT_PUBLIC_WEBVIEW=1
yarn build-web
# Paths
ROOT_ENV=".env" # your root .env
WEB_ENV="web/.env" # target for frontend
# Backup existing web/.env if it exists
if [ -f "$WEB_ENV" ]; then
cp "$WEB_ENV" "${WEB_ENV}.bak"
echo "Backed up existing $WEB_ENV to ${WEB_ENV}.bak"
fi
# Filter NEXT_PUBLIC_* lines
grep '^NEXT_PUBLIC_' "$ROOT_ENV" > "$WEB_ENV"
echo "Copied NEXT_PUBLIC_ variables to $WEB_ENV:"
echo "NEXT_PUBLIC_FIREBASE_ENV=prod" >> "$WEB_ENV"
cat "$WEB_ENV"
cd web
rm -rf .next
# Hack to ignore getServerSideProps, getStaticProps and getStaticPaths for mobile webview build
# as Next.js doesn't support SSG, SSR and ISR on mobile
USERNAME_PAGE=pages/[username]/index.tsx
HOME_PAGE=pages/index.tsx
# rename getStaticProps to _getStaticProps
sed -i.bak 's/\bgetStaticProps\b/_getStaticProps/g' $USERNAME_PAGE
# rename getStaticPaths to _getStaticPaths
sed -i.bak 's/\bgetStaticPaths\b/_getStaticPaths/g' $USERNAME_PAGE
# rename getServerSideProps to _getServerSideProps
sed -i.bak 's/\bgetServerSideProps\b/_getServerSideProps/g' $HOME_PAGE
yarn build
sed -i.bak 's/\b_getStaticProps\b/getStaticProps/g' $USERNAME_PAGE
sed -i.bak 's/\b_getStaticPaths\b/getStaticPaths/g' $USERNAME_PAGE
sed -i.bak 's/\b_getServerSideProps\b/getServerSideProps/g' $HOME_PAGE