Skip to content

Instantly share code, notes, and snippets.

View ayyash's full-sized avatar

Ayyash ayyash

View GitHub Profile
@ayyash
ayyash / index.ts
Last active October 2, 2022 17:52
Rewriting _renderUniversal
// in index.ts, simplify
async function _renderUniversal(
routes: string[],
context: BuilderContext,
clientPath: string,
serverPath: string,
indexFile: string
): Promise<BuilderOutput> {
// the server bundle is server/main.js
@ayyash
ayyash / worker.ts
Created October 2, 2022 17:54
The PreRender worker function
export async function PreRender({
indexFile,
clientPath,
serverBundlePath,
route,
}: RenderOptions): Promise<RenderResult> {
const result = {} as RenderResult;
// this is the index.html
@ayyash
ayyash / angular.json
Created October 2, 2022 17:55
Minimun required specs for Angular Prerender
{
"newProjectRoot": "projects",
"projects": {
"cr": {
// ...
"prefix": "cr",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
@ayyash
ayyash / index.ts
Created October 2, 2022 17:57
Rewriting Execute function
export async function execute(
options: IOptions,
context: BuilderContext,
): Promise<BuilderOutput> {
// read browser options and setup the clientPath
const browserTarget = targetFromTargetString(options.browserTarget);
const browserOptions = (await context.getTargetOptions(browserTarget)) as any;
const clientPath = path.resolve(context.workspaceRoot, browserOptions.outputPath );