Skip to content

Instantly share code, notes, and snippets.

@iyasilias
Last active July 6, 2020 05:01
Show Gist options
  • Save iyasilias/1bfee53fb3fd5fc0d1605fcdf22f458f to your computer and use it in GitHub Desktop.
Save iyasilias/1bfee53fb3fd5fc0d1605fcdf22f458f to your computer and use it in GitHub Desktop.
1. ng add @angular/pwa
2. ionic build --prod
3. copy www to server (rename the folder if you wish)
4. rename manifest.webmanifest to manifest.json (if your server have problem with .webmanifest extension)
5. open manifest.json and edit the file
from
"name": "app",
"short_name": "app",
"theme_color": "#1976d2",
"background_color": "#fafafa",
"display": "standalone",
"scope": "./",
"start_url": "./",
to
"name": "<your app name>",
"short_name": "<your app name>",
"theme_color": "#1976d2",
"background_color": "#fafafa",
"display": "standalone",
"scope": "/<your app folder>/",
"start_url": "/<your app folder>/",
6. Edit ngsw.json: Line 52 & 317 from "/manifest.webmanifest" to "/manifest.json"
7. Edit index.html:
from <title>Ionic App</title> to <title><your app name></title>
8. Edit index.html:
Add
<meta name="description" content="<your app description>">
<meta property="og:title" content="<your app name>" />
<meta property="og:url" content="<your pwa url>" />
<meta property="og:description" content="<your app description>">
<meta property="og:image" content="<your app logo url>">
9. Edit index.html:
from <base href="/"/> to <base href="/<your app folder>/"/>
10. Edit index.html:
At line 20, add <link rel="apple-touch-icon" href="assets/icon/favicon.png"/>
11. Edit index.html:
from <link rel="manifest" href="manifest.webmanifest"> to <link rel="manifest" href="manifest.json">
12. Make sure you copy all your custom icons into folder assets/icon and assets/icons
13. Your app will get error if user reload/refresh the page. This can be solved with server configuration. Please google "ionic pwa error when refresh"
Basically, it involve rewrite function.
For firebase: your firebase.json should look like this
{
"hosting": {
"public": "www",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
],
"headers": [
{
"source": "/build/app/**",
"headers": [
{
"key": "Cache-Control",
"value": "public, max-age=31536000"
}
]
},
{
"source": "sw.js",
"headers": [
{
"key": "Cache-Control",
"value": "no-cache"
}
]
}
]
}
}
For Apache:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment