Skip to content

Commit 37ee775

Browse files
committed
Fix build-web-view
1 parent f650ab7 commit 37ee775

File tree

4 files changed

+47
-55
lines changed

4 files changed

+47
-55
lines changed

android/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ javac -version
7676

7777
```
7878
yarn install
79-
yarn build-web
79+
yarn build-web-view
8080
```
8181
8282
### Local mode
@@ -110,7 +110,7 @@ cd android
110110
Sync web files and native plugins with Android, for offline fallback. In root:
111111
```
112112
export NEXT_PUBLIC_LOCAL_ANDROID=1 # if running your local web Compass
113-
yarn build-web # if you made changes to web app
113+
yarn build-web-view # if you made changes to web app
114114
npx cap sync android
115115
```
116116

@@ -247,7 +247,7 @@ yarn dev # or prod
247247

248248
# Terminal 2: start frontend
249249
export NEXT_PUBLIC_LOCAL_ANDROID=1
250-
yarn build-web # if you made changes to web app
250+
yarn build-web-view # if you made changes to web app
251251
npx cap sync android
252252
# Run on emulator or device
253253
```
@@ -275,7 +275,7 @@ npm install -g @capawesome/cli@latest
275275
npx @capawesome/cli login
276276
```
277277

278-
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.
278+
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.
279279
```
280280
yarn build-web-view
281281
npx @capawesome/cli apps:bundles:create --path web/out

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
"dev": "./scripts/run_local.sh dev",
1717
"prod": "./scripts/run_local.sh prod",
1818
"clean-install": "./scripts/install.sh",
19-
"build-web": "./scripts/build_web.sh",
20-
"build-web-view": "./scripts/build_web.sh",
19+
"build-web-view": "./scripts/build_web_view.sh",
2120
"build-sync-android": "./scripts/build_sync_android.sh",
2221
"sync-android": "./scripts/sync_android.sh",
2322
"migrate": "./scripts/migrate.sh",

scripts/build_web.sh

Lines changed: 0 additions & 48 deletions
This file was deleted.

scripts/build_web_view.sh

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,45 @@ cd "$(dirname "$0")"/..
66

77
export NEXT_PUBLIC_WEBVIEW=1
88

9-
yarn build-web
9+
# Paths
10+
ROOT_ENV=".env" # your root .env
11+
WEB_ENV="web/.env" # target for frontend
12+
13+
# Backup existing web/.env if it exists
14+
if [ -f "$WEB_ENV" ]; then
15+
cp "$WEB_ENV" "${WEB_ENV}.bak"
16+
echo "Backed up existing $WEB_ENV to ${WEB_ENV}.bak"
17+
fi
18+
19+
# Filter NEXT_PUBLIC_* lines
20+
grep '^NEXT_PUBLIC_' "$ROOT_ENV" > "$WEB_ENV"
21+
22+
echo "Copied NEXT_PUBLIC_ variables to $WEB_ENV:"
23+
24+
echo "NEXT_PUBLIC_FIREBASE_ENV=prod" >> "$WEB_ENV"
25+
26+
cat "$WEB_ENV"
27+
28+
cd web
29+
30+
rm -rf .next
31+
32+
# Hack to ignore getServerSideProps, getStaticProps and getStaticPaths for mobile webview build
33+
# as Next.js doesn't support SSG, SSR and ISR on mobile
34+
USERNAME_PAGE=pages/[username]/index.tsx
35+
HOME_PAGE=pages/index.tsx
36+
37+
# rename getStaticProps to _getStaticProps
38+
sed -i.bak 's/\bgetStaticProps\b/_getStaticProps/g' $USERNAME_PAGE
39+
40+
# rename getStaticPaths to _getStaticPaths
41+
sed -i.bak 's/\bgetStaticPaths\b/_getStaticPaths/g' $USERNAME_PAGE
42+
43+
# rename getServerSideProps to _getServerSideProps
44+
sed -i.bak 's/\bgetServerSideProps\b/_getServerSideProps/g' $HOME_PAGE
45+
46+
yarn build
47+
48+
sed -i.bak 's/\b_getStaticProps\b/getStaticProps/g' $USERNAME_PAGE
49+
sed -i.bak 's/\b_getStaticPaths\b/getStaticPaths/g' $USERNAME_PAGE
50+
sed -i.bak 's/\b_getServerSideProps\b/getServerSideProps/g' $HOME_PAGE

0 commit comments

Comments
 (0)