Code Monkey home page Code Monkey logo

fontawesome-module's Introduction

@nuxtjs/fontawesome

npm version npm downloads Circle CI License

Module to use Font Awesome icons in your Nuxt.js project. Uses vue-fontawesome under the hood

๐Ÿ“– Release Notes

Setup

  • Add dependency using npm to your project
$ yarn add @nuxtjs/fontawesome -D

// or to also add the free icon packs

$ yarn add @nuxtjs/fontawesome @fortawesome/free-solid-svg-icons @fortawesome/free-brands-svg-icons -D
  • Add @nuxtjs/fontawesome to buildModules in your nuxt.config
  • Configure loaded icons/whole sets

Use the 'fontawesome' key:

  // nuxt.config.js
  buildModules: [
    '@nuxtjs/fontawesome',
  ],

  fontawesome: {
    icons: {
      solid: ['faCog', ...],
      ...
    }
  }
}

or include the options in the modules listing

  // nuxt.config.js
  buildModules: [
    ['@nuxtjs/fontawesome', {
      component: 'fa',
      suffix: true,
      proIcons: { // if you have bought the Pro packages
        // list the icons you want to add, not listed icons will be tree-shaked
        solid: [
          'faHome',
          'faHeart'
        ],
        // include all icons. But dont do this.
        regular: true
      }
    }]
  ]

Module options

component

  • Default: FontAwesomeIcon

Change component name. Eg set to fa to use <fa icon="" ... />. Also see suffix

It's strongly recommended to use PascalCase for component names

useLayers

  • Default: true

Boolean to indicate if the layers component should be registered globally. Name of the component will be ${options.component}-layers, fe <fa-layers ... />

useLayersText

  • Default: true

Boolean to indicate if the layers component should be registered globally. Name of the component will be the ${options.component}-layers-text, fe <fa-layers-text ... />

icons

Which icons you will use. FontAwesome currently supports 5 icon styles of which 3 are freely available (partially).

This option is an object with the style names as property and an array with all icon names you wish to use from those styles

  icons: {
    solid: [ 'faHome', ... ],
    regular: [ ... ],
    light: [ ... ],
    duotone: [ ... ],
    brands: [ ...]
  }

Although not recommended, you can use true to include the full icon set:

  icons: {
    solid: true
  }

proIcons

See icons for how to use, but always uses pro imports.

addCss

  • Default: true

If the module should automatically add the fontawesome styles to the global css config. It works by unshifting @fortawesome/fontawesome-svg-core/styles.css onto the nuxt.options.css property.

suffix

  • Default: false

Boolean whether to append -icon to the icon component name. This option exists as the component name option is also used for the layer components and you might not want to add '-icon' to those

  // config
  component: 'Fa',
  suffix: true

  // usage
  <fa-icon />
  <fa-layer />
  // config
  component: 'FaIcon',
  suffix: false

  // usage
  <fa-icon />
  <fa-icon-layers />

imports deprecated

Import icons/whole sets from chosen packages. This is the old configuration and will likely be removed in a future version. Use icons instead

  • Default: [], no icons will be imported here (see below, can be loaded later inside .vue file)
    • set - path to node package for import, like @fortawesome/free-solid-svg-icons
    • icons - array of icons to import ['faAdjust', 'faArchive'].
  imports: [
    {
      set: '@fortawesome/free-solid-svg-icons',
      icons: ['faHome']
    }
  ]

Usage

You can find more details under example folder. Also please see vue-fontawesome for additional reference

  • Ensure you have installed an icon package yarn add @fortawesome/free-solid-svg-icons -D
  • and have added the module configuration to your nuxt.config.js

Default component names are:

  • <font-awesome-icon>
  • <font-awesome-layers>
  • <font-awesome-layers-text>

With component option set, -layers and -layers-text suffixes will be appended (see example below)

  // nuxt.config
  fontawesome: {
    icons: {
      solid: ['faHome'],
      regular: ['faAdjust']
    }
  },
  • Use global icons:
<template>
  <div>
    <font-awesome-icon :icon="['fas', 'adjust']"  />
    <font-awesome-icon icon="dollar-sign"  style="font-size: 30px"/>
    <font-awesome-icon icon="cog"/>

    <font-awesome-layers class="fa-4x">
      <font-awesome-icon icon="circle"/>
      <font-awesome-icon icon="check" transform="shrink-6" :style="{ color: 'white' }"/>
    </font-awesome-layers>

    <font-awesome-layers full-width class="fa-4x">
      <font-awesome-icon icon="calendar"/>
      <font-awesome-layers-text transform="shrink-8 down-3" value="27" class="fa-inverse" />
    </font-awesome-layers>
  </div>
</template>

<script></script>
  • Use locally imported icons
<template>
    <div>
        <fa-layers full-width class="fa-4x">
          <fa :icon="fas.faCircle"/>
          <fa-layers-text transform="shrink-12" value="GALSD" class="fa-inverse" />
        </fa-layers>

        <fa :icon="fas.faAddressBook"  />
        <fa :icon="faGithub" />
    </div>
</template>

<script>
import { fas } from '@fortawesome/free-solid-svg-icons'
import { faGithub } from '@fortawesome/free-brands-svg-icons'

export default {
  computed: {
    fas () {
       return fas // NOT RECOMMENDED
    },
    faGithub () {
       return faGithub
    }
  },
}
</script>

Integrations

Storybook

If you are fan of storybook this might be interesting for you, This module provides a story to list and search available icons of your project. You can see stories under stories directory. If you are using @nuxtjs/storybook you can see the fontawesome stories under Modules section in your storybook. By default Font Awesome story will shows in your storybook, you disable/hide the story using Storybook's modules option

License

MIT License

This module was forked from the (font) awesome module created by Galley Web Development

Copyright (c) Nuxt Community

fontawesome-module's People

Contributors

farnabaz avatar pimlie avatar rokasdie avatar vaso2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

fontawesome-module's Issues

Brand icons are not loading

Solid icons are loading but Brand icons are not. Any ideas if this is a bug?

Screenshot-2021-09-11-171158

nuxt.config.js file

...
buildModules: [
    '@nuxtjs/fontawesome',
],
...
fontawesome: {
    icons: {
        brands: [
            'faFacebookSquare',
            'faGithubSquare',
            'faInstagram',
            'faLinkedin',
            'faPinterestSquare',
            'faTelegram',
            'faTwitterSquare',
            'faVimeoSquare',
            'faWhatsappSquare',
        ],
        solid: [
            'faCircle',
            'faDesktop',
            'faFilePdf',
            'faMobileAlt',
            'faPhoneSquareAlt',
            'faPencilRuler',
            'faServer',
        ],
    },
},

package.json

...
"@fortawesome/fontawesome-svg-core": "^1.2.36",
"@fortawesome/free-brands-svg-icons": "^5.15.4",
"@fortawesome/free-regular-svg-icons": "^5.15.4",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@fortawesome/vue-fontawesome": "^2.0.2",
"@nuxtjs/fontawesome": "^1.1.2",
...

Missing dependency declarations

The current build (1.1.2) misses the following:

  • peer dependency declaration for vue, as @fortawesome/vue-fontawesome has one declared.
  • consola dependency (not declared in package.json)

I can open a PR, just react/answer :)

Problem using fas icons

I have this html code

<fa :icon="['fas', 'arrow-next']" />

nuxt.config.js

...
fontawesome: {
   icons: {
      solid: [ ..., 'fasArrowNext']
   }
}
...

and I am having an error in console

./.nuxt/fontawesome.js 10:105-124"export 'fasArrowLeft' (imported as 'freeFasFasArrowLeft') was not found in '@fortawesome/free-solid-svg-icons'./.nuxt/fontawesome.js 10:83-103"export 'fasArrowRight' (imported as 'freeFasFasArrowRight') was not found in '@fortawesome/free-solid-svg-icons'

I've already added @fortawesome/free-solid-svg-icons. How do I fix this? Thanks in advance ๐Ÿ˜„

jest mock

I've installed this package plus the fortawesome ones and everything works OK.

this is my config:

  buildModules: [
    ....
    ['nuxt-fontawesome', {
      component: 'fa',
      imports: [
        {
          set: '@fortawesome/free-solid-svg-icons',
          icons: ['fas']
        },
        {
          set: '@fortawesome/free-regular-svg-icons',
          icons: ['far']
        }
      ]
    }]
  ],

when I run tests jest complaining about:

 [Vue warn]: Unknown custom element: <fa> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

how can I stub it?

Typescript support

AFAIK there are no type definitions; or are they in a different module?

Nuxt 3 compatibility?

just tried to generate my nuxt site with npx nuxi generate

using nuxt rc-3

getting this warning:

WARN                                                                          15:54:43
(!) Some chunks are larger than 500 KiB after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/guide/en/#outputmanualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.

โ„น Client built in 15227ms                                                      15:54:43
โ„น Building server...                                                           15:54:43

 WARN  @fortawesome/fontawesome-pro doesn't appear to be written in CJS, but also doesn't appear to be a valid ES module (i.e. it doesn't have "type": "module" or an .mjs extension for the entry point). Please contact the package author to fix.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Using npm packages for Renovate presets is now deprecated. Please migrate to repository-based presets instead.

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

circleci
.circleci/config.yml
npm
package.json
  • @fortawesome/fontawesome-svg-core ^1.2.27
  • @fortawesome/vue-fontawesome ^0.1.9
  • @fortawesome/free-brands-svg-icons ^5.12.1
  • @fortawesome/free-solid-svg-icons ^5.12.1
  • @nuxtjs/eslint-config ^2.0.2

  • Check this box to trigger a request for Renovate to run again on this repository

Module not working

Version

@nuxt/cli v2.15.6
node v14.17.0

Config

Screenshot from 2021-06-06 06-48-17

Usage

<fa :icon="['fab', 'github']"/>

Screenshot from 2021-06-06 06-43-04

Don't deprecate `imports` option.

My suggestion is to not deprecate this option, but tweak it for a slightly different use.

For those that aren't aware all those that had the license for Font Awesome 5, can no longer install Font Awesome from their official npm repository. The license is not longer valid, but there's also a guide in the official docs where it is shown that you can download the .tar and host it somewhere privately for your personal use.

Since this breaks one of my projects and I do not wish to pay $100/y for Font Awesome v6, my only option is to follow that guide.

Hosting Font Awesome myself under my private Git repository of a project, under different scope. So without this imports option, I wouldn't be able to provide a set of the pro icons (v5) that are still valid.

I hope I was able to provide valuable information here. Please keep this option for such purposes.

For example, this is the config that I'm currently using:

fontawesome: {
    component: 'Fa',
    suffix: false,
    useLayers: false,
    useLayersText: false,
    icons: {
      brands: [
        'faCcVisa',
        'faCcMastercard',
        'faCcDiscover',
        'faCcAmex',
        'faCcPaypal',
        'faLinkedinIn',
        'faInstagram',
        'faTwitter'
      ]
    },
    imports: [
      {
        set: '@xxx/xxx-xxx-xxx',
        icons: [
          'faUsersCrown',
          // ...
        ]
      }
    ]
}

Cannot read property 'prefix' of undefined

I tried to followed all the step as mentioned here: https://www.npmjs.com/package/@nuxtjs/fontawesome

My nuxt.config.js

buildModules: [
    // https://go.nuxtjs.dev/typescript
    '@nuxt/typescript-build',
    ['@nuxtjs/fontawesome',{
      component: 'fa',
      suffix: true,
    },],
  ],
fontawesome: {
    icons: {
      solid: ['faHome'],
      regular: ['faUserSecret'],
      brands: ['faGithub'],
    }
  },

My usage of the component

<fa :icon="['fab', 'github']"/>

Expected outcome:
Works out of the box

Actual Outcome:
App crashes with the following error on the console
image

Icons are fine in dev but huge in production build

I've been using your package for a while and everything was working fine. However, after updating last week the Icons turned huge (as in 640 x 562 px) when in production mode. when in development mode everything is fine. I cant figure out what is causing this.. any idea?

Usage of Pro Icons

I've added the fontawesome token to be able to download the pro icons and I've added this packages as dev dependencies:

    "@fortawesome/fontawesome-pro": "^5.13.0",
    "@fortawesome/free-solid-svg-icons": "^5.13.0",
    "@fortawesome/pro-duotone-svg-icons": "^5.13.0",
    "@fortawesome/pro-light-svg-icons": "^5.13.0",
    "@fortawesome/pro-regular-svg-icons": "^5.13.0",
    "@fortawesome/pro-solid-svg-icons": "^5.13.0",
    "@nuxtjs/fontawesome": "^1.1.2",

but this error appears when trying to use a light icon (PRO icon)

 ERROR  Failed to compile with 1 errors                                                                                                                                                                                  

This dependency was not found:                                                                                                                                                                                          

* @fortawesome/free-light-svg-icons in ./.nuxt/fontawesome.js                                                                                                                                                            

To install it, you can run: npm install --save @fortawesome/free-light-svg-icons 

This is the fontawesome config in nuxt.config

  fontawesome: {
    icons: {
      light: ['faAbacus']
    }
  },

Could not find one or more icon

I've did everything the Readme told me to, but I can't get any icons to work if I try to import them in my nuxt.config.js, only when I import them directly in a component.

Could not find one or more icon(s) {
  prefix: 'fas',
  iconName: 'faGithub'
} {}
buildModules: [
    [
      '@nuxtjs/fontawesome',
      {
        component: 'fa',
      },
    ],
  ],
fontawesome: {
  icons: {
    brands: ['faGithub'],
  },
},
<fa icon="faGithub" />

Storybook support not available in the latest NPM release

Hi,

I saw the library support @nuxtjs/storybook but it seems that the latest release doesn't correspond with the code in the repository.
I also saw a pull request for Typescript support that haven't been merged.

Is it normal or this is just a missing update on the NPM side ? Is the repos is abandoned ?

FontAwesome 6 Support

Hello,

Are you planning on supporting the new FontAwesome 6 version (which is still in Beta, but accessible to subscribers)?

Thanks

Any way to reduce bundle size after tree shaking?

After correctly using tree shaking (I'm using about 20 icons, no layers) and setting:

    addCss: false,
    useLayers: false,
    useLayersText: false,

in module config, my top size in bundle is fontawesome-svg-core which includes some unuseful code for my needs and it seems there's no way to limit its size. Am I missing something? thanks
image

[Vue warn]: Unknown custom element: <font-awesome-icon>

Hi guys, i am getting error,
[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.

nuxt.config.js

buildModules: [
    '@nuxtjs/fontawesome',
  ],
fontawesome: {
    icons: {
      solid: true
    }
  }

Used in template like this
<font-awesome-icon icon="cog"/>

Thanks!

[Vue warn]: Unknown custom element: XXX did you register the component correctly? For recursive components, make sure to provide the "name" option.

nuxt.config.js
Screen Shot 2021-03-20 at 6 59 41 AM

Jest test case
Screen Shot 2021-03-20 at 7 01 29 AM

pages/order/index.vue
Screen Shot 2021-03-20 at 7 01 57 AM

error message.
Screen Shot 2021-03-20 at 7 02 11 AM

//package.json
{
  "name": "XXXXX",
  "version": "1.0.0",
  "type": "module",
  "description": "XXXX",
  "author": "XXX",
  "private": true,
  "scripts": {
    "dev": "HOST=0.0.0.0 PORT=3232 nuxt",
    "dev:debug": "node --inspect node_modules/.bin/nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "test": "jest",
    "test:unit": "jest --watch",
    "generate": "nuxt generate",
    "lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
    "lintfix": "eslint --fix --ext .js,.vue --ignore-path .gitignore .",
    "lint:dryrun": "eslint --fix-dry-run --ext .js,.ts,.vue --ignore-path .gitignore .",
    "heroku-postbuild": "npm run build",
    "lint-staged": "lint-staged",
    "commitlint": "commitlint",
    "commit": "git-cz"
  },
  "config": {
    "commitizen": {
      "path": "cz-conventional-changelog"
    }
  },
  "lint-staged": {
    "**/*.{js,jsx,ts,tsx}": [
      "eslint --cache --fix",
      "git add ."
    ]
  },
  "husky": {
    "hooks": {
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
      "pre-commit": "lint-staged"
    }
  },
  "dependencies": {
    "@nuxt/typescript-build": "^2.1.0",
    "@nuxtjs/axios": "^5.13.1",
    "@nuxtjs/google-analytics": "^2.4.0",
    "jquery": "^3.6.0",
    "nuxt-edge": "^2.16.0-26936677.9247190c",
    "vue-flex-waterfall": "^1.0.7",
    "vue-instagram": "^1.2.0"
  },
  "devDependencies": {
    "@babel/core": "^7.13.10",
    "@babel/preset-env": "^7.13.10",
    "@commitlint/cli": "^11.0.0",
    "@commitlint/config-conventional": "^11.0.0",
    "@fortawesome/fontawesome-free": "^5.15.3",
    "@fortawesome/free-brands-svg-icons": "^5.15.3",
    "@fortawesome/free-solid-svg-icons": "^5.15.3",
    "@nuxt/types": "^2.15.3",
    "@nuxt/typescript": "^2.8.1",
    "@nuxtjs/fontawesome": "^1.1.2",
    "@nuxtjs/tailwindcss": "^4.0.1",
    "@types/jest": "^26.0.20",
    "@vue/test-utils": "^1.1.3",
    "babel-core": "^7.0.0-bridge.0",
    "babel-eslint": "^10.1.0",
    "babel-jest": "^26.6.3",
    "commitizen": "^4.2.3",
    "eslint": "^7.22.0",
    "eslint-config-prettier": "^8.1.0",
    "eslint-config-standard": "^16.0.2",
    "eslint-loader": "^4.0.2",
    "eslint-plugin-html": "^6.1.2",
    "eslint-plugin-import": "^2.7.0",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-nuxt": "^2.0.0",
    "eslint-plugin-prettier": "^3.3.1",
    "eslint-plugin-promise": "^4.3.1",
    "eslint-plugin-standard": "^5.0.0",
    "fibers": "^5.0.0",
    "husky": "^5.1.3",
    "iview": "^3.5.4",
    "iview-loader": "^1.0.0-beta.4",
    "jest": "^26.6.3",
    "jest-transform-stub": "^2.0.0",
    "lint-staged": "^10.5.4",
    "mutationobserver-shim": "^0.3.7",
    "postcss": "^8.2.8",
    "prettier": "^2.2.1",
    "sass": "^1.32.8",
    "sass-loader": "^10.1.1",
    "stylus": "^0.54.5",
    "stylus-loader": "^4.3.3",
    "ts-jest": "^26.5.3",
    "vue": "^2.4.4",
    "vue-agile": "^0.2.6",
    "vue-awesome": "^2.3.3",
    "vue-gallery": "^2.0.1",
    "vue-i18n": "^8.24.1",
    "vue-jest": "^3.0.7",
    "vue-waterfall": "^1.0.6"
  }
}

Hi, I'm running into the following error with this module with my jest tests.

    [Vue warn]: Unknown custom element: <fa> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
    
    found in

I also see that another issue similar to mine is open but didn't provide a definitive answer.
#21

Any examples of configuration using self-hosted packages?

Are there any examples or suggestions for the nuxt.config setup if using self-hosted fontAwesome packages? I noticed that if purchasing a pro license and not renewing, the icons will no longer be available via .npmrc and the app will break.

Is there any known solution for this?

Brand icons not loading in production build

Hi, does someone having this problem:

fontawesome: { component: 'fa', icons: { solid: true, brands: true, }, },

<fa :icon="['fab', 'linkedin']"/>

The icons is loaded in dev mode but not in build. The SVG tag is there but not showing the icon.

how do i add a custom kit using imports?

i have created a custom kit in font awesome but i cant add the icon to my project.
using package.json:
"nuxt-fontawesome": "^0.4.0",
"nuxt": "^2.15.8",
"@fortawesome/fontawesome-pro": "^6.1.1",
"@fortawesome/fontawesome-svg-core": "^6.1.1",
"@fortawesome/free-brands-svg-icons": "^6.1.1",
"@fortawesome/free-solid-svg-icons": "^6.1.1",
"@fortawesome/pro-duotone-svg-icons": "^6.1.1",
"@fortawesome/pro-light-svg-icons": "^6.1.1",
"@fortawesome/pro-regular-svg-icons": "^6.1.1",
"@fortawesome/pro-solid-svg-icons": "^6.1.1",

in nuxt.config.js
modules: [
[
"nuxt-fontawesome",
{
imports: [...]
]

what set should i use?

thanks!

Fontawesome icons not being loaded from pro folder

Using Fontawesome Pro I installed the package @fortawesome/fontawesome-pro as their documentation recommends. When using a duotone icon (premium), e.g. stars, I am told by the Nuxt development server to install @fortawesome/pro-duotone-svg-icons. Doing so removes the error message, but I'm not sure if this was really necessary:
I found the desired svg file contained in the only package that the official documentation told me to install: node_modules/@fortawesome/fontawesome-pro/svgs/duotone/stars.svg
Is this something I misunderstand, like a missing additional file contained in the other package, or should the extension support loading from the full package as well? It appeared to me that while you're able too install certain styles only, the (currently) recommended package contains all the styles already.
I've seen some documentations suggest that the general package only installs the regular style, but that turned out to be incorrect in my case.

Got issue when npm run build `ERROR Cannot read properties of undefined (reading 'fontawesome') `

Got issue when npm run build,
anyone encounter this? thanks

Nuxi 3.0.0 15:36:26
Nuxt 3.0.0 with Nitro 1.0.0 15:36:26

ERROR Cannot read properties of undefined (reading 'fontawesome') 15:36:26

at module (node_modules/nuxt-fontawesome/lib/module.js:9:56)
at installModule (node_modules/@nuxt/kit/dist/index.mjs:416:9)
at async initNuxt (node_modules/nuxt/dist/index.mjs:1823:7)
at async loadNuxt (node_modules/nuxt/dist/index.mjs:1857:5)
at async loadNuxt (node_modules/@nuxt/kit/dist/index.mjs:493:19)
at async Object.invoke (node_modules/nuxi/dist/chunks/build.mjs:34:18)
at async _main (node_modules/nuxi/dist/cli.mjs:50:20)

Regular free icon not showing in production build

Loads fine on local dev, but not loading on a SSR build on live server.

The markup in my vue page component is:

<fa-icon class="copy-icon" :icon="['far', 'copy']" />

Inspecting page code on the live site I can see the html has the fa-icon markup as follows, instead of svg:

<fa-icon icon="far,copy" class="copy-icon"></fa-icon>

Any help greatly appreciated.

Nuxt 2.15.8
@nuxtjs/fontawesome: ^1.1.2
@fortawesome/free-regular-svg-icons: ^6.1.1
@fortawesome/vue-fontawesome: 0.1.10 (via @nuxtjs/fontawesome)

nuxt.config.js:

buildModules: [
    ['@nuxtjs/fontawesome', {
      component: 'fa',
      icons: {
        regular: [ 'faCopy' ],
      },
    }],
]

Unknow custom element: <fa>

hi guys, i got this error and i did everything that you said in the docs

Im using the latest version of nuxt.js

Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.

found in

---> <Pages/index.vue> at pages/index.vue

<Layouts/default.vue> at layouts/default.vue

Any tougths ?

Oversized icons in a statically generated site

I believe my issue is similar to this one here: FortAwesome/vue-fontawesome#14

I am using Nuxt.js to build and deploy on netlify. I run npm run generate there to generate the statically generated site and deploy the dist folder to the server. While in "dev mode" with npm run dev, all icons are displayed correctly and tailwindcss font-styles are applied. On prod they are massively oversized.

Expected:
website

Current state:
oversized

I tried to apply the nuxt.js instructions from the old repo (link above), but to no avail.

// nuxt.config.js
...
  buildModules: [
    // Doc: https://github.com/nuxt-community/eslint-module
    '@nuxtjs/eslint-module',
    // Doc: https://github.com/nuxt-community/nuxt-tailwindcss
    '@nuxtjs/tailwindcss',
    // Docs: https://github.com/nuxt-community/fontawesome-module
    '@nuxtjs/fontawesome'
  ],
  tailwindcss: {
    configPath: '~/tailwind.config.js',
    cssPath: '~/assets/css/tailwind.css',
    purgeCSSInDev: false
  },
  fontawesome: {
    suffix: true,
    icons: {
      solid: ['faRss'],
      brands: ['faGitlab', 'faGithub', 'faDocker', 'faTwitter', 'faXing']
    }
  },
...
// index.vue
<template>
  <main class="flex flex-1 flex-col md:flex-row md:justify-center pt-10">
    <section class="w-full md:w-5/8 mb-16 md:mb-0">
      <Slogan
        class="text-2xl sm:text-4xl md:text-5xl lg:text-6xl xl:text-7xl pt-0 md:pt-12 mb-6 sm:mb-8 md:mb-12 font-hairline "
      />
      <ul class="flex flex-row flex-wrap">
        <li v-for="(link, index) in links" :key="index" class="mr-6 mb-6 sm:mr-8 md:mr-6 lg:mr-6">
          <a :href="link.href" target="_blank" rel="noopener noreferrer"
            ><FontAwesomeIcon
              :icon="link.icon"
              class="text-xl sm:text-2xl md:text-xl lg:text-3xl xl:text-4xl cursor-pointer transform transition duration-300 ease-in-out hover:scale-125"
              :class="'hover:' + link.hover"
          /></a>
        </li>
      </ul>
    </section>
    <section class="w-full md:w-3/8 p-12 md:p-0">
      <img
        src="~/assets/img/home.svg"
        alt="A man builds a website on an oversized screen surrounded by nature."
        class="transform  transition duration-500 ease-in-out hover:opacity-90"
      />
    </section>
  </main>
</template>

<script>
import Slogan from '~/components/Slogan.vue'

export default {
  components: {
    Slogan
  },
  data() {
    return {
      links: [
        {
          href: 'https://gitlab.com/m.dirim',
          icon: ['fab', 'gitlab'],
          hover: 'text-orange-500'
        },
        {
          href: 'https://github.com/leeniu',
          icon: ['fab', 'github'],
          hover: 'text-indigo-500'
        },
        {
          href: 'https://hub.docker.com/u/malikdirim',
          icon: ['fab', 'docker'],
          hover: 'text-blue-500'
        },
        {
          href: 'https://malikdirim.me',
          icon: ['fas', 'rss'],
          hover: 'text-red-500'
        },
        {
          href: 'https://twitter.com/malikdirim',
          icon: ['fab', 'twitter'],
          hover: 'text-blue-500'
        },
        {
          href: 'https://www.xing.com/profile/Malik_Dirim/',
          icon: ['fab', 'xing'],
          hover: 'text-green-500'
        }
      ]
    }
  }
}
</script>

<style lang="scss"></style>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.