Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standalone + SSR #407

Closed
Judp0m opened this issue Jun 18, 2023 · 5 comments
Closed

Standalone + SSR #407

Judp0m opened this issue Jun 18, 2023 · 5 comments

Comments

@Judp0m
Copy link

Judp0m commented Jun 18, 2023

What is the support for Standalone (no modules) and Server Side Rendering?

Without the Standalone mode, icons show up properly in the server-generated version of my app.
With standalone, the icons are blank for the SSR page, and then get populated once the client takes over. So it flashes after a couple seconds of loading (load SSR page, no icons, load the app, bootstraps the app, then the icons show up).
This causes layout shifts and is obviously undesirable.

If it is supported, could we get a guide or clarity?
If not supported, consider that a feature request.

@devoto13
Copy link
Collaborator

What is the support for Standalone (no modules) and Server Side Rendering?

Have never tested it, so not sure. Let's consider it a feature request to write a guide/test and fix it if needed.

@DominicWrege
Copy link

Standalone would be awesome

@msacket
Copy link

msacket commented Dec 11, 2023

A similar problem for me is that the icons are initially displaying too large with the SSR. A flash later, once the website hydrates client-side and the font-awesome CSS is injected, they shrink to the correct size. For my particular use case, copying the relevant css to the main scss works around this issue:

svg:not(:root).svg-inline--fa, svg:not(:host).svg-inline--fa {
    overflow: visible;
    box-sizing: content-box;
}
.svg-inline--fa {
    display: var(--fa-display, inline-block);
    height: 1em;
    overflow: visible;
    vertical-align: -0.125em;
}

@kewur
Copy link

kewur commented Jan 14, 2024

@msacket 's workaround used to work for me in the module based ssr, but doesn't work with standalone

@natehitze-eventlink
Copy link

I got a different workaround from https://www.skovy.dev/blog/server-side-rendering-font-awesome

We don't use standalone but I think the only difference is how you inject the document: https://stackoverflow.com/a/76719683

import { Inject } from '@angular/core';
import { CommonModule, DOCUMENT } from "@angular/common";
import { config, dom } from "@fortawesome/fontawesome-svg-core";

...

export class AppModule {
  constructor(@Inject(DOCUMENT) private document: Document) {
    // This code was heavily inspired by https://www.skovy.dev/blog/server-side-rendering-font-awesome
    // FontAwesome icons loaded the way we do start HUGE initially until the CSS is injected. This injects the CSS immediately.
    config.autoAddCss = false; // Disable FA's CSS injection
    let head = this.document.getElementsByTagName("head")[0];
    let styleNode = this.document.createElement("style");
    styleNode.innerHTML = dom.css(); // grab FA's CSS
    head.appendChild(styleNode);
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants