Node学園 26時限目
Progressive
Responsive
Connectivity Independent
App-like
Fresh
Safe
Discoverable
Re-engageable
Installable
Linkable
Progressive
Responsive
Connectivity Independent => Cache
App-like => App Shell
Fresh => Cache Strategy
Safe
Discoverable
Re-engageable => Push
Installable
Linkable
Node.js上でAngularアプリケーションを実行
実行結果をHTML文字列として取得できる
index.htmlの代わりに配信
import { renderModule } from '@angular/platform-server';
import { AppServerModule } from './app/app.module.server';
renderModule(AppServerModule, {
document: readFileSync(resolve('dist/index.html'), 'utf8'),
url: '/'
}).then(result => {
writeFileSync(resolve('dist/index.html'), result);
});
import { NgModule } from '@angular/core';
import { ServerModule } from '@angular/platform-server';
import { AppComponent } from './app.component';
import { AppModule } from './app.module';
@NgModule({
imports: [ AppModule, ServerModule ],
bootstrap: [AppComponent]
})
export class AppServerModule { }
AngularでPWAを構築するためのツール群
@angular/app-shell
@angular/service-worker
App Shellに含める / 含めない要素を指定できる
*shellRender
*shellNoRender
import { AppShellModule } from '@angular/app-shell';
@NgModule({
imports: [ AppModule, ServerModule, AppShellModule.prerender() ],
bootstrap: [AppComponent]
})
export class AppServerModule { }
<header appHeader></header>
<main appContent *shellNoRender></main>
<main *shellRender>
<md-progress-bar mode="indeterminate"></md-progress-bar>
</main>
Angular supports PWA officially