From 824919f0d7957b8a561bb6a08a5812da93dbdaa5 Mon Sep 17 00:00:00 2001 From: Austin Date: Mon, 22 Jan 2018 11:19:24 -0600 Subject: [PATCH] feat(sw): adds ngsw config (#350) --- material.angular.io/angular-cli.json | 2 +- material.angular.io/ngsw-manifest.json | 10 ------ material.angular.io/src/app/app-module.ts | 4 ++- material.angular.io/src/ngsw-config.json | 38 +++++++++++++++++++++++ 4 files changed, 42 insertions(+), 12 deletions(-) delete mode 100644 material.angular.io/ngsw-manifest.json create mode 100644 material.angular.io/src/ngsw-config.json diff --git a/material.angular.io/angular-cli.json b/material.angular.io/angular-cli.json index b95b48b22f19..ab3c1cbb0dda 100644 --- a/material.angular.io/angular-cli.json +++ b/material.angular.io/angular-cli.json @@ -16,7 +16,7 @@ "test": "test.ts", "tsconfig": "tsconfig.json", "prefix": "app", - "serviceWorker": false, + "serviceWorker": true, "styles": [ "main.scss", "highlightjs/material-light.css", diff --git a/material.angular.io/ngsw-manifest.json b/material.angular.io/ngsw-manifest.json deleted file mode 100644 index 4df2cda4d2c0..000000000000 --- a/material.angular.io/ngsw-manifest.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "external": { - "urls": [ - {"url": "https://fonts.googleapis.com/icon?family=Material+Icons"}, - {"url": "https://fonts.googleapis.com/css?family=Roboto:300,400,500|Roboto+Mono:300"}, - {"url": "https://ajax.googleapis.com/ajax/libs/hammerjs/2.0.8/hammer.min.js"}, - {"url": "https://cdnjs.cloudflare.com/ajax/libs/web-animations/2.2.5/web-animations.min.js"} - ] - } -} diff --git a/material.angular.io/src/app/app-module.ts b/material.angular.io/src/app/app-module.ts index 02fad8cfb50c..9560b519d93e 100644 --- a/material.angular.io/src/app/app-module.ts +++ b/material.angular.io/src/app/app-module.ts @@ -33,6 +33,8 @@ import { CanActivateComponentSidenav } from './pages/component-sidenav/component-sidenav-can-load-guard'; import {HttpClientModule} from '@angular/common/http'; +import {ServiceWorkerModule} from '@angular/service-worker'; +import {environment} from '../environments/environment'; @NgModule({ imports: [ @@ -44,7 +46,7 @@ import {HttpClientModule} from '@angular/common/http'; HttpClientModule, MatNativeDateModule, RouterModule.forRoot(MATERIAL_DOCS_ROUTES), - + ServiceWorkerModule.register('/ngsw-worker.js', {enabled: environment.production}), ComponentCategoryListModule, ComponentHeaderModule, ComponentListModule, diff --git a/material.angular.io/src/ngsw-config.json b/material.angular.io/src/ngsw-config.json new file mode 100644 index 000000000000..2dc816d8e2cd --- /dev/null +++ b/material.angular.io/src/ngsw-config.json @@ -0,0 +1,38 @@ +{ + "index": "/index.html", + "assetGroups": [{ + "name": "app", + "installMode": "prefetch", + "resources": { + "files": [ + "/favicon.ico", + "/index.html" + ], + "versionedFiles": [ + "/*.bundle.css", + "/*.bundle.js", + "/*.chunk.js" + ] + } + }, { + "name": "assets", + "installMode": "prefetch", + "resources": { + "files": [ + "/assets/**" + ] + } + }, { + "name": "static-assets", + "installMode": "lazy", + "updateMode": "prefetch", + "resources": { + "urls": [ + "https://fonts.googleapis.com/icon?family=Material+Icons", + "https://fonts.googleapis.com/css?family=Roboto|Roboto+Mono", + "https://ajax.googleapis.com/ajax/libs/hammerjs/2.0.8/hammer.min.js", + "https://cdnjs.cloudflare.com/ajax/libs/web-animations/2.2.5/web-animations.min.js" + ] + } + }] +} \ No newline at end of file