Skip to content

Commit

Permalink
feat(sw): adds ngsw config (angular#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
amcdnl authored and jelbourn committed Jan 22, 2018
1 parent 3d5a970 commit b7d033a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 12 deletions.
2 changes: 1 addition & 1 deletion angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"serviceWorker": false,
"serviceWorker": true,
"styles": [
"main.scss",
"highlightjs/material-light.css",
Expand Down
10 changes: 0 additions & 10 deletions ngsw-manifest.json

This file was deleted.

4 changes: 3 additions & 1 deletion src/app/app-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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,
Expand Down
38 changes: 38 additions & 0 deletions src/ngsw-config.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}]
}

0 comments on commit b7d033a

Please sign in to comment.