Universal + pwaの構成でprerender時にservice workerが出力されない

ng new pp
ng add @nguniversal/hapi-engine
ng add @angular/pwa --project pp
npm run prerender
% tree dist                                                                                                                                                                                                                                                                 ✹ ✭
dist
└── pp
    ├── browser
    │   ├── 3rdpartylicenses.txt
    │   ├── assets
    │   │   └── icons
    │   │       ├── icon-128x128.png
    │   │       ├── icon-144x144.png
    │   │       ├── icon-152x152.png
    │   │       ├── icon-192x192.png
    │   │       ├── icon-384x384.png
    │   │       ├── icon-512x512.png
    │   │       ├── icon-72x72.png
    │   │       └── icon-96x96.png
    │   ├── favicon.ico
    │   ├── index.html
    │   ├── index.original.html
    │   ├── main-es2015.1ae6494e61633d717eae.js
    │   ├── main-es5.1ae6494e61633d717eae.js
    │   ├── manifest.webmanifest
    │   ├── polyfills-es2015.690002c25ea8557bb4b0.js
    │   ├── polyfills-es5.1fd9b76218eca8053895.js
    │   ├── runtime-es2015.1eba213af0b233498d9d.js
    │   ├── runtime-es5.1eba213af0b233498d9d.js
    │   └── styles.09e2c710755c8867a460.css
    └── server
        └── main.js

5 directories, 21 files
% ng version                                                                                                                                                                                                                                                                

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 9.1.6
Node: 10.19.0
OS: darwin x64

Angular: 9.1.7
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router, service-worker
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.901.6
@angular-devkit/build-angular     0.901.6
@angular-devkit/build-optimizer   0.901.6
@angular-devkit/build-webpack     0.901.6
@angular-devkit/core              9.1.6
@angular-devkit/schematics        9.1.6
@angular/cli                      9.1.6
@ngtools/webpack                  9.1.6
@nguniversal/builders             9.1.1
@nguniversal/common               9.1.1
@nguniversal/hapi-engine          9.1.1
@schematics/angular               9.1.6
@schematics/update                0.901.6
rxjs                              6.5.5
typescript                        3.8.3
webpack                           4.42.0

prerenderのbuildに関してはproductionでbuildしているはずなんですが、出てきていません
よろしくお願いします。

ng build --prod

% tree dist                                                                                                                                                                                                                                                                 ✹ 
dist
└── pp
    ├── browser
    │   ├── 3rdpartylicenses.txt
    │   ├── assets
    │   │   └── icons
    │   │       ├── icon-128x128.png
    │   │       ├── icon-144x144.png
    │   │       ├── icon-152x152.png
    │   │       ├── icon-192x192.png
    │   │       ├── icon-384x384.png
    │   │       ├── icon-512x512.png
    │   │       ├── icon-72x72.png
    │   │       └── icon-96x96.png
    │   ├── favicon.ico
    │   ├── index.html
    │   ├── main-es2015.1ae6494e61633d717eae.js
    │   ├── main-es5.1ae6494e61633d717eae.js
    │   ├── manifest.webmanifest
    │   ├── ngsw-worker.js
    │   ├── ngsw.json
    │   ├── polyfills-es2015.690002c25ea8557bb4b0.js
    │   ├── polyfills-es5.1fd9b76218eca8053895.js
    │   ├── runtime-es2015.1eba213af0b233498d9d.js
    │   ├── runtime-es5.1eba213af0b233498d9d.js
    │   ├── safety-worker.js
    │   ├── styles.09e2c710755c8867a460.css
    │   └── worker-basic.min.js
    └── server
        └── main.js

5 directories, 24 files

この場合は出力されている

無理やり解決

prerenderで出力されたindex.htmlを一度退避させて、production ビルド時のindex.htmlを差し替えてやる
hash周りでindex.htmlが確定しないから出せないんだろうなと考えてますけど、prerenderで出したいな

Issueが見つかりました。まだOpenですね

1 Likes