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.

Icons load incorrectly (very large) in server side when using library.add (Nuxt.js)

See original GitHub issue

Icons render initially very large until finally settling down to wanted size. I’m using nuxt with server side rendering.

Fontawesome gets loaded as a plugin with nuxt.js:

import fontawesome from '@fortawesome/fontawesome'
import iconCSS from './icon-css.css'
import {
  faFrown
} from '@fortawesome/fontawesome-free-solid'

fontawesome.dom.styles(iconCSS)

fontawesome.library.add(
  faFrown
)

export default fontawesome

Am I missing something here? Is there a workaround for this behavior?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:14
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

29reactions
OriginalEXEcommented, Dec 13, 2017

@chewtoys Here is my example (using the pro version):

font-awesome.js (place in the plugins folder):

import fontawesome from '@fortawesome/fontawesome';
import { faCoffee, faCode } from '@fortawesome/fontawesome-pro-regular';

fontawesome.config = {
  autoAddCss: false,
};

fontawesome.library.add(faCoffee, faCode);

nuxt.config.js (relevant part)

css: [
  '@fortawesome/fontawesome/styles.css',
],
plugins: [
  '~/plugins/font-awesome',
],

index.vue

<template>
  <div>
    <p>Hello! <font-awesome-icon :icon="['far', 'code']"></font-awesome-icon><p>
  </div>
</template>

<script>
import FontAwesomeIcon from '@fortawesome/vue-fontawesome';

export default {
  components: {
    FontAwesomeIcon,
  },
};
</script>
16reactions
samuelterra22commented, Nov 13, 2018

I had the same problem using Nuxtjs but I fixed just reading the readme

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Actual Fix To The NuxtJS + UIkit Icons Loading Issue
This video looks at a simple fix to the icon loading issue with NuxtJS and the UIkit front-end framework. NuxtJS by default does...
Read more >
Server-side rendering with Vue and Nuxt.js - LogRocket Blog
In this container, we have a special tag app , which will contain content parsed by Vue. The server is now only responsible...
Read more >
vue.js - How can I dynamically load svg icons from ...
You can try to make method in components/BaseCryptoIcon.vue:
Read more >
How to Configure SSG and SSR on Nuxt.js - Mad Devs
In this case, we will not load frontend with additional code + all the tokens will be on the server side, which is...
Read more >
Understand and solve hydration errors in Vue.js - sum.cumo
If a component is initially mounted or hydrated in the DOM, it needs to precisely correspond to the HTML generated on the server...
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