question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make this component better for SSR

See original GitHub issue

I’m using SSR to prerender a page into a static HTML file (Vuepress)

Our FontAwesomeIcon can be prerendered, but not so perfect.

At the first glance when opening the page, it looks like this:

image

After the scripting, it display well:

image

The first glance is really annoying, so currently, I hacked our component to avoid being prerendered:

import FontAwesomeIcon from '@fortawesome/vue-fontawesome'
Vue.component('FontAwesomeIcon', {
    functional: true,
    props: FontAwesomeIcon.props,
    render (h, context) {
      if (context.parent._isMounted) {
        return h(FontAwesomeIcon, context)
      } else {
        context.parent.$once('hook:mounted', () => {
          context.parent.$forceUpdate()
        })
      }
    }
  })

The cause of this issue is that the <style> is injected by js script, so only after scripting will it display well. (Could not be extracted by ExtractTextPlugin)

If we can put the styles into our component’s <style> section, like some other vue components, then it could be extracted correctly.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:4
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

10reactions
robmadolecommented, Jul 4, 2018

@dariuszlorek we know how to fix it. Just haven’t done the work yet 😉

5reactions
dariuszlorekcommented, Jul 4, 2018

That’s still unresolved. @robmadole think about some way to fix it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A beginner's guide to React Server-Side Rendering (SSR)
In this lesson, we are going to talk about server-side rendering (SSR), its benefits, and its pitfalls. Then we will set up a...
Read more >
Improve app performance with React server-side rendering
SSR apps offer faster initial load times and better SEO performance compared to client-side rendered apps, there are some downsides. First, ...
Read more >
Using Web Components With Next (or Any SSR Framework)
Our first step is to create a single JavaScript module that imports all of our Web Component definitions. For the Shoelace components I'm...
Read more >
How to Enable Server-Side Rendering for a React App
Server-side rendering (SSR) is a popular technique for rendering a client-side single page application (SPA) on the server and then sending a ...
Read more >
Server-Side Rendering (SSR) - Vue.js
Why SSR? # ... Compared to a client-side Single-Page Application (SPA), the advantage of SSR primarily lies in: ... Better SEO: the search...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found