function render(outputPath, serverBundlePath, route) {
        return __awaiter(this, void 0, void 0, function* () {
            const result = {};
            const browserIndexOutputPath = path.join(outputPath, workerArgs.indexFile);
            const outputFolderPath = path.join(outputPath, route);
            const outputIndexPath = path.join(outputFolderPath, 'index.html');
            const { renderModule, AppServerModule } = yield __syncRequire ? Promise.resolve().then(() => require(serverBundlePath)) : new Promise((resolve_1, reject_1) => { require([serverBundlePath], resolve_1, reject_1); });
            const browserIndexInputPath = path.join(outputPath, workerArgs.indexFile);
            let indexHtml = yield fs.promises.readFile(browserIndexInputPath, 'utf8');
            indexHtml = indexHtml.replace('</html>', '<!-- This page was prerendered with Angular Universal -->\n</html>');
            if (workerArgs.inlineCriticalCss) {
                // Workaround for https://github.com/GoogleChromeLabs/critters/issues/64
                indexHtml = indexHtml.replace(/ media=\"print\" onload=\"this\.media='all'"><noscript><link .+?><\/noscript>/g, '>');
            }
            let html = yield renderModule(AppServerModule, {
                document: indexHtml,
                url: route,
            });
            if (inlineCriticalCssProcessor) {
                const { content, warnings, errors } = yield inlineCriticalCssProcessor.process(html, {
                    outputPath,
                });
                result.errors = errors;
                result.warnings = warnings;
                html = content;
            }
            // This case happens when we are prerendering "/".
            if (browserIndexOutputPath === outputIndexPath) {
                const browserIndexOutputPathOriginal = path.join(outputPath, 'index.original.html');
                fs.renameSync(browserIndexOutputPath, browserIndexOutputPathOriginal);
            }
            fs.mkdirSync(outputFolderPath, { recursive: true });
            fs.writeFileSync(outputIndexPath, html);
            return result;
        });
    }
/**
     * Renders each route in routes and writes them to <outputPath>/<route>/index.html.
     */
Renders each route in routes and writes them to //index.html.
Renders each route in routes and writes them to // index . html .
function render(outputPath, serverBundlePath, route) {
        return __awaiter(this, void 0, void 0, function* () {
            const result = {};
            const browserIndexOutputPath = path.join(outputPath, workerArgs.indexFile);
            const outputFolderPath = path.join(outputPath, route);
            const outputIndexPath = path.join(outputFolderPath, 'index.html');
            const { renderModule, AppServerModule } = yield __syncRequire ? Promise.resolve().then(() => require(serverBundlePath)) : new Promise((resolve_1, reject_1) => { require([serverBundlePath], resolve_1, reject_1); });
            const browserIndexInputPath = path.join(outputPath, workerArgs.indexFile);
            let indexHtml = yield fs.promises.readFile(browserIndexInputPath, 'utf8');
            indexHtml = indexHtml.replace('</html>', '<!-- This page was prerendered with Angular Universal -->\n</html>');
            if (workerArgs.inlineCriticalCss) {
                indexHtml = indexHtml.replace(/ media=\"print\" onload=\"this\.media='all'"><noscript><link .+?><\/noscript>/g, '>');
            }
            let html = yield renderModule(AppServerModule, {
                document: indexHtml,
                url: route,
            });
            if (inlineCriticalCssProcessor) {
                const { content, warnings, errors } = yield inlineCriticalCssProcessor.process(html, {
                    outputPath,
                });
                result.errors = errors;
                result.warnings = warnings;
                html = content;
            }
            if (browserIndexOutputPath === outputIndexPath) {
                const browserIndexOutputPathOriginal = path.join(outputPath, 'index.original.html');
                fs.renameSync(browserIndexOutputPath, browserIndexOutputPathOriginal);
            }
            fs.mkdirSync(outputFolderPath, { recursive: true });
            fs.writeFileSync(outputIndexPath, html);
            return result;
        });
    }
function render ( outputPath , serverBundlePath , route ) { return __awaiter ( this , void 0 , void 0 , function * ( ) { const result = { } ; const browserIndexOutputPath = path . join ( outputPath , workerArgs . indexFile ) ; const outputFolderPath = path . join ( outputPath , route ) ; const outputIndexPath = path . join ( outputFolderPath , 'index.html' ) ; const { renderModule , AppServerModule } = yield __syncRequire ? Promise . resolve ( ) . then ( ( ) => require ( serverBundlePath ) ) : new Promise ( ( resolve_1 , reject_1 ) => { require ( [ serverBundlePath ] , resolve_1 , reject_1 ) ; } ) ; const browserIndexInputPath = path . join ( outputPath , workerArgs . indexFile ) ; let indexHtml = yield fs . promises . readFile ( browserIndexInputPath , 'utf8' ) ; indexHtml = indexHtml . replace ( '</html>' , '<!-- This page was prerendered with Angular Universal -->\n</html>' ) ; if ( workerArgs . inlineCriticalCss ) { indexHtml = indexHtml . replace ( /  media=\"print\" onload=\"this\.media='all'"><noscript><link .+?><\/noscript> / g , '>' ) ; } let html = yield renderModule ( AppServerModule , { document : indexHtml , url : route , } ) ; if ( inlineCriticalCssProcessor ) { const { content , warnings , errors } = yield inlineCriticalCssProcessor . process ( html , { outputPath , } ) ; result . errors = errors ; result . warnings = warnings ; html = content ; } if ( browserIndexOutputPath === outputIndexPath ) { const browserIndexOutputPathOriginal = path . join ( outputPath , 'index.original.html' ) ; fs . renameSync ( browserIndexOutputPath , browserIndexOutputPathOriginal ) ; } fs . mkdirSync ( outputFolderPath , { recursive : true } ) ; fs . writeFileSync ( outputIndexPath , html ) ; return result ; } ) ; }
Renders each route in routes and writes them to <outputPath>/<route>/index.html.
Renders each route in routes and writes them to <outputPath > / <route > / index . html .
// Workaround for https://github.com/GoogleChromeLabs/critters/issues/64 // This case happens when we are prerendering "/".