diff --git a/android/README.md b/android/README.md index 48153cf8..59a419ab 100644 --- a/android/README.md +++ b/android/README.md @@ -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 diff --git a/package.json b/package.json index 3822e1b4..14b2f5ff 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/build_web.sh b/scripts/build_web.sh deleted file mode 100755 index 6cb5c7b3..00000000 --- a/scripts/build_web.sh +++ /dev/null @@ -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 diff --git a/scripts/build_web_view.sh b/scripts/build_web_view.sh index 64bf2e7e..730fc7da 100755 --- a/scripts/build_web_view.sh +++ b/scripts/build_web_view.sh @@ -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