Skip to content

Commit

Permalink
chore: Update web build command to fix 404 error and PWA padding issue (
Browse files Browse the repository at this point in the history
#3)

* chore: Update web build command to fix 404 error and PWA padding issue

* chore: Update envfile creation in GitHub workflows

* Disable web build
  • Loading branch information
hectorAguero authored May 8, 2024
1 parent 7329784 commit 4671998
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 20 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ jobs:
with:
channel: beta
cache: true
# Not needed for tests but pubspec.yaml requires it
- name: Make envfile
uses: SpicyPizza/[email protected]
with:
envkey_API_URL: ${{ secrets.API_URL }}
run: echo "API_URL=${{ secrets.API_URL }}" > .env

- run: flutter test
16 changes: 7 additions & 9 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Github-Pages
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

jobs:
Expand All @@ -21,18 +19,18 @@ jobs:
cache: true

- name: Make envfile
uses: SpicyPizza/[email protected]
with:
envkey_API_URL: ${{ secrets.API_URL }}

- name: Run Tests
run: flutter test
run: echo "API_URL=${{ secrets.API_URL }}" > .env

- name: Install dependencies
run: flutter pub get

- name: Run Tests
run: flutter test

# 404.html and flutter_bootstrap.js are mannually added to the web folder to
# fix the 404 error on GH Pages and fix PWA Padding issue
- name: Build web
run: flutter build web --wasm --base-href /batucadapp/
run: flutter build web --wasm --base-href /batucadapp/ --no-web-resources-cdn

- name: Commit changes
run: |
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,4 @@ app.*.map.json
/android/app/profile
/android/app/release

# Until I change the config for dev and release
web/flutter_bootstrap.js
.env*
Binary file added assets/fonts/Roboto-Regular.ttf
Binary file not shown.
6 changes: 6 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ dev_dependencies:
flutter:
uses-material-design: true
generate: true
# Flutter engine issue, always download roboto on
# web in the loadAssetFonts function https://github.com/flutter/engine/blob/main/lib/web_ui/lib/src/engine/canvaskit/fonts.dart
fonts:
- family: Roboto
fonts:
- asset: assets/fonts/Roboto-Regular.ttf

assets:
# Add assets from the images directory to the application.
Expand Down
2 changes: 1 addition & 1 deletion web/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Redirecciona a index.html -->
<!-- Redirect to index.html, cant figure out how to use dynamic href here, so for is batucadapp-->
<meta http-equiv="refresh" content="0; URL='/batucadapp/'" />
<title>404 - redirect</title>
</head>
Expand Down
5 changes: 1 addition & 4 deletions web/flutter_bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ function leftInset() {
{{flutter_build_config}}
window.addEventListener("load", (_) => {
_flutter.loader.load({
config: {
// Use the local CanvasKit bundle instead of the CDN to reduce test flakiness.
canvasKitBaseUrl: '/batucadapp/canvaskit/',
},

onEntrypointLoaded: (engineInitializer) => {
engineInitializer.initializeEngine().then((appRunner) => {
appRunner.runApp().then((_) => {
Expand Down

0 comments on commit 4671998

Please sign in to comment.