Skip to content

Commit

Permalink
feat(service-worker): add basic service-worker config
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieuher committed Jan 5, 2025
1 parent 94caa8f commit 50a8871
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 51 deletions.
4 changes: 3 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
}
],
"styles": ["src/styles.scss"],
"scripts": []
"scripts": [],
"serviceWorker": true,
"ngswConfigPath": "ngsw-config.json"
},
"configurations": {
"production": {
Expand Down
21 changes: 21 additions & 0 deletions ngsw-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": ["/favicon.ico", "/index.csr.html", "/index.html", "/manifest.webmanifest", "/*.css", "/*.js"]
}
},
{
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": ["/assets/**/*.(png|svg|mp3)"]
}
}
]
}
95 changes: 48 additions & 47 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,49 @@
{
"name": "retroski",
"version": "1.1.2",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"lint": "biome lint --write src",
"format": "biome format --write src",
"postbuild": "cp src/.htaccess dist/"
},
"private": true,
"dependencies": {
"@angular/animations": "^19.0.5",
"@angular/common": "^19.0.5",
"@angular/compiler": "^19.0.5",
"@angular/core": "^19.0.5",
"@angular/forms": "^19.0.5",
"@angular/platform-browser": "^19.0.5",
"@angular/platform-browser-dynamic": "^19.0.5",
"@angular/router": "^19.0.5",
"date-fns": "4.1.0",
"dexie": "^4.0.9",
"excalibur": "0.30.2",
"pocketbase": "0.22.1",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.15.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^19.0.5",
"@angular/cli": "^19.0.5",
"@angular/compiler-cli": "^19.0.5",
"@biomejs/biome": "1.9.4",
"@types/jasmine": "~5.1.0",
"@types/node": "22.10.2",
"jasmine-core": "~5.1.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.6.3",
"vite": "^5.0.0"
}
}
"name": "retroski",
"version": "1.1.2",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"lint": "biome lint --write src",
"format": "biome format --write src",
"postbuild": "cp src/.htaccess dist/"
},
"private": true,
"dependencies": {
"@angular/animations": "^19.0.5",
"@angular/common": "^19.0.5",
"@angular/compiler": "^19.0.5",
"@angular/core": "^19.0.5",
"@angular/forms": "^19.0.5",
"@angular/platform-browser": "^19.0.5",
"@angular/platform-browser-dynamic": "^19.0.5",
"@angular/router": "^19.0.5",
"@angular/service-worker": "^19.0.5",
"date-fns": "4.1.0",
"dexie": "^4.0.9",
"excalibur": "0.30.2",
"pocketbase": "0.22.1",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.15.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^19.0.5",
"@angular/cli": "^19.0.5",
"@angular/compiler-cli": "^19.0.5",
"@biomejs/biome": "1.9.4",
"@types/jasmine": "~5.1.0",
"@types/node": "22.10.2",
"jasmine-core": "~5.1.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.6.3",
"vite": "^5.0.0"
}
}
Binary file added public/icons/icon-128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/icon-144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/icon-152x152.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/icon-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/icon-384x384.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/icon-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/icon-72x72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/icon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/manifest.webmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "RetroSki",
"short_name": "RetroSki",
"description": "Retroski is a small game development project designed for peaceful mountain rides and friendly competition. Challenge your friends on randomly generated 2D alpine ski tracks!",
"description": "Retroski is a small game development project designed for peaceful mountain rides and friendly competition.",
"theme_color": "#9747ff",
"lang": "en",
"background_color": "#ffffff",
Expand Down
8 changes: 6 additions & 2 deletions src/app/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { type ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
import { type ApplicationConfig, provideZoneChangeDetection, isDevMode } from '@angular/core';
import { provideRouter, withHashLocation } from '@angular/router';

import { routes } from './app.routes';
import { provideServiceWorker } from '@angular/service-worker';

export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes, withHashLocation())]
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes, withHashLocation()), provideServiceWorker('ngsw-worker.js', {
enabled: !isDevMode(),
registrationStrategy: 'registerWhenStable:30000'
})]
};
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,13 @@
dependencies:
tslib "^2.3.0"

"@angular/service-worker@^19.0.5":
version "19.0.5"
resolved "https://registry.yarnpkg.com/@angular/service-worker/-/service-worker-19.0.5.tgz#5ae776df8b75161b87dcaf735102ad161cc99541"
integrity sha512-qU5lgx1WJ+feCOV/EhkN9m20xFdIslpEQcSZZC+VJnEwcG6VTbofg1dRaHWZ9HAjS1uP7bFoK0HUYu4el0bHGA==
dependencies:
tslib "^2.3.0"

"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.25.9", "@babel/code-frame@^7.26.0", "@babel/code-frame@^7.26.2":
version "7.26.2"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.26.2.tgz#4b5fab97d33338eff916235055f0ebc21e573a85"
Expand Down

0 comments on commit 50a8871

Please sign in to comment.