使用 Angular 5.1.2 Angular-cli 1.6.3
所有文件都很普通。dist 文件夹已创建
我的 ngsw-config.json
{
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html"
],
"versionedFiles": [
"/*.bundle.css",
"/*.bundle.js",
"/*.chunk.js"
]
}
},
{
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**"
]
}
}]
}
我的 app.module.ts 使用
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production })
我正在使用香草 environment.ts 和 environment.prod.ts
主要的.ts
import './polyfills.ts';
import {enableProdMode} from '@angular/core';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './app/app.module';
import {environment} from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule)
.then(() => {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('ngsw-worker.js');
}
})
.catch(err => console.log(err));
不知道还有什么要检查的