Skip to content

Commit

Permalink
feat(@nguniversal/common): enable inlining of critical CSS by default
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-agius4 committed Feb 19, 2021
1 parent 98c51a3 commit 3dddb75
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/common/engine/src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export class CommonEngine {
* render options
*/
async render(opts: RenderOptions): Promise<string> {
const { inlineCriticalCss = true } = opts;

if (opts.publicPath && opts.documentFilePath && opts.url !== undefined) {
const url = new URL(opts.url);
// Remove leading forward slash.
Expand Down Expand Up @@ -94,7 +96,7 @@ export class CommonEngine {
extraProviders.push({
provide: INITIAL_CONFIG,
useValue: {
document: opts.inlineCriticalCss
document: inlineCriticalCss
// Workaround for https://github.com/GoogleChromeLabs/critters/issues/64
? doc.replace(/ media=\"print\" onload=\"this\.media='all'"><noscript><link .+?><\/noscript>/g, '>')
: doc,
Expand All @@ -107,7 +109,7 @@ export class CommonEngine {
const factory = await this.getFactory(moduleOrFactory);

const html = await renderModuleFactory(factory, { extraProviders });
if (!opts.inlineCriticalCss) {
if (!inlineCriticalCss) {
return html;
}

Expand Down

0 comments on commit 3dddb75

Please sign in to comment.