Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/universal-app/DEBUG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ the file will be stored in the `bazel-out` folder.

You can retrieve the path to the file by either running:

* `bazel test //src/universal-app:server_test --test_output=all`
* `echo $(bazel info bazel-bin)/src/universal-app/index-prerendered.html`
* `bazel run //src/universal-app:server_test --test_output=all`
* `echo $(bazel info bazel-testlogs)/src/universal-app/server_test/test.outputs/index-prerendered.html`
30 changes: 15 additions & 15 deletions src/universal-app/prerender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ import {KitchenSinkRootServerModuleNgFactory} from './kitchen-sink-root.ngfactor
const indexHtmlPath = require.resolve('./index.html');

const result = renderModuleFactory(
KitchenSinkRootServerModuleNgFactory,
{document: readFileSync(indexHtmlPath, 'utf-8')});
KitchenSinkRootServerModuleNgFactory, {document: readFileSync(indexHtmlPath, 'utf-8')});
const outDir = process.env.TEST_UNDECLARED_OUTPUTS_DIR as string;

result
.then(content => {
const filename = join(__dirname, 'index-prerendered.html');
.then(content => {
const filename = join(outDir, 'index-prerendered.html');

console.log('Inspect pre-rendered page here:');
console.log(`file://${filename}`);
writeFileSync(filename, content, 'utf-8');
console.log('Prerender done.');
})
// If rendering the module factory fails, print the error and exit the process
// with a non-zero exit code.
.catch(error => {
console.error(error);
process.exit(1);
});
console.log('Inspect pre-rendered page here:');
console.log(`file://${filename}`);
writeFileSync(filename, content, 'utf-8');
console.log('Prerender done.');
})
// If rendering the module factory fails, print the error and exit the process
// with a non-zero exit code.
.catch(error => {
console.error(error);
process.exit(1);
});