Add pwa fix files, disable publishing
This commit is contained in:
44
.github/workflows/gh-pages.yml
vendored
44
.github/workflows/gh-pages.yml
vendored
@@ -22,6 +22,9 @@ on:
|
|||||||
- ".github/workflows/**"
|
- ".github/workflows/**"
|
||||||
- "scripts/**"
|
- "scripts/**"
|
||||||
|
|
||||||
|
env:
|
||||||
|
HREFREPLACE: "IIITB_Menu"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build
|
name: Build
|
||||||
@@ -68,11 +71,18 @@ jobs:
|
|||||||
# run: flutter test
|
# run: flutter test
|
||||||
|
|
||||||
- name: Build Web Release
|
- name: Build Web Release
|
||||||
run: flutter build web --base-href "/IIITB_Menu/" --web-renderer canvaskit
|
run: flutter build web --base-href "/$HREFREPLACE/" --web-renderer canvaskit --no-web-resources-cdn
|
||||||
|
|
||||||
- name: Build Android Release
|
- name: Build Android Release
|
||||||
run: flutter build apk --split-per-abi --release --no-track-widget-creation --analyze-size --target-platform "android-arm64"
|
run: flutter build apk --split-per-abi --release --no-track-widget-creation --analyze-size --target-platform "android-arm64"
|
||||||
|
|
||||||
|
- name: Fix PWA Offline Support
|
||||||
|
run: |
|
||||||
|
cp scripts/fixOfflinePWA.sh .
|
||||||
|
chmod +x fixOfflinePWA.sh
|
||||||
|
./fixOfflinePWA.sh
|
||||||
|
cat ./build/web/flutter_service_worker.js
|
||||||
|
|
||||||
- name: Create Release
|
- name: Create Release
|
||||||
uses: marvinpinto/action-automatic-releases@v1.2.1
|
uses: marvinpinto/action-automatic-releases@v1.2.1
|
||||||
with:
|
with:
|
||||||
@@ -89,21 +99,21 @@ jobs:
|
|||||||
name: production-files
|
name: production-files
|
||||||
path: ./build/web
|
path: ./build/web
|
||||||
|
|
||||||
deploy:
|
# deploy:
|
||||||
name: Deploy
|
# name: Deploy
|
||||||
needs: build
|
# needs: build
|
||||||
runs-on: ubuntu-latest
|
# runs-on: ubuntu-latest
|
||||||
if: github.ref == 'refs/heads/master'
|
# if: github.ref == 'refs/heads/master'
|
||||||
|
|
||||||
steps:
|
# steps:
|
||||||
- name: Download artifact
|
# - name: Download artifact
|
||||||
uses: actions/download-artifact@v2.1.1
|
# uses: actions/download-artifact@v2.1.1
|
||||||
with:
|
# with:
|
||||||
name: production-files
|
# name: production-files
|
||||||
path: ./build
|
# path: ./build
|
||||||
|
|
||||||
- name: Deploy to gh-pages
|
# - name: Deploy to gh-pages
|
||||||
uses: peaceiris/actions-gh-pages@v3.9.3
|
# uses: peaceiris/actions-gh-pages@v3.9.3
|
||||||
with:
|
# with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
# github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
publish_dir: ./build
|
# publish_dir: ./build
|
||||||
|
|||||||
6
scripts/fixOfflinePWA.sh
Normal file
6
scripts/fixOfflinePWA.sh
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
cp scripts/pwaOffline.patch .
|
||||||
|
sed -e "s/HREFREPLACE/$(echo $HREFREPLACE)\//g" pwaOffline.patch > fix.patch
|
||||||
|
mv build/web/flutter_service_worker.js .
|
||||||
|
patch flutter_service_worker.js < fix.patch
|
||||||
|
mv flutter_service_worker.js build/web/
|
||||||
53
scripts/pwaOffline.patch
Normal file
53
scripts/pwaOffline.patch
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
--- menu/build/web/flutter_service_worker.js 2024-01-26 14:59:42.195084752 +0530
|
||||||
|
+++ in/flutter_service_worker.pat.js 2024-01-26 15:07:37.253097455 +0530
|
||||||
|
@@ -2,6 +2,7 @@
|
||||||
|
const MANIFEST = 'flutter-app-manifest';
|
||||||
|
const TEMP = 'flutter-temp-cache';
|
||||||
|
const CACHE_NAME = 'flutter-app-cache';
|
||||||
|
+const BaseHREF = 'HREFREPLACE';
|
||||||
|
|
||||||
|
const RESOURCES = {
|
||||||
|
"version.json": "d7fbd41faace5a7a02bb5da13e6049ec",
|
||||||
|
@@ -37,10 +38,7 @@
|
||||||
|
};
|
||||||
|
// The application shell files that are downloaded before a service worker can
|
||||||
|
// start.
|
||||||
|
-const CORE = ["main.dart.js",
|
||||||
|
-"index.html",
|
||||||
|
-"assets/AssetManifest.json",
|
||||||
|
-"assets/FontManifest.json"];
|
||||||
|
+const CORE = Object.keys(RESOURCES);
|
||||||
|
|
||||||
|
// During install, the TEMP cache is populated with the application shell files.
|
||||||
|
self.addEventListener("install", (event) =>
|
||||||
|
@@ -139,13 +137,30 @@
|
||||||
|
{
|
||||||
|
key = key.split('?v=')[0];
|
||||||
|
}
|
||||||
|
- if (event.request.url == origin || event.request.url.startsWith(origin + '/#') || key == '') {
|
||||||
|
+ if (key.endsWith("chromium/canvaskit.js"))
|
||||||
|
+ {
|
||||||
|
+ key = "canvaskit/chromium/canvaskit.js"
|
||||||
|
+ }
|
||||||
|
+ if (key.endsWith("chromium/canvaskit.wasm"))
|
||||||
|
+ {
|
||||||
|
+ key = "canvaskit/chromium/canvaskit.wasm"
|
||||||
|
+ }
|
||||||
|
+ if (key.endsWith("canvaskit.js"))
|
||||||
|
+ {
|
||||||
|
+ key = "canvaskit/canvaskit.js"
|
||||||
|
+ }
|
||||||
|
+ if (key.endsWith("canvaskit.wasm"))
|
||||||
|
+ {
|
||||||
|
+ key = "canvaskit/canvaskit.wasm"
|
||||||
|
+ }
|
||||||
|
+ if (event.request.url == origin || event.request.url.startsWith(origin + '/#') || key == '' || key == BaseHREF) {
|
||||||
|
key = '/';
|
||||||
|
}
|
||||||
|
// If the URL is not the RESOURCE list then return to signal that the
|
||||||
|
// browser should take over.
|
||||||
|
- if (!RESOURCES[key]) {
|
||||||
|
+ var resKey = key.replace(BaseHREF, "");
|
||||||
|
+ if (!RESOURCES[resKey]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user