vue-fontawesome icon indicating copy to clipboard operation
vue-fontawesome copied to clipboard

Huge js file generated when used with nuxt3 in ssr mode

Open Blakeinstein opened this issue 2 years ago • 7 comments

Describe the bug An unminified inlinded css as a js template string is added to built files when using vue-fontawesome with nuxt3.

Reproducible test case https://codesandbox.io/s/compassionate-leavitt-3ehro?file=/plugins/fontawesome.ts Here is a repro of this issue. Simple open the preview window in a new window then check the js files generated in the dev console (in sources/debugger tab). This has been a major hurdle in me getting a decent lighthouse score.

Expected behavior With config.autoAddCss = false no css should exist in the build files.

Desktop (please complete the following information):

  • Browser : all
  • Version: "@fortawesome/vue-fontawesome": "3.0.0-5"

Additional context I have followed the instructions for nuxt, but that doesnt seem to fix it. Additionally, webpack 5 is being used as the bundler in nuxt3.

Blakeinstein avatar Feb 02 '22 13:02 Blakeinstein

https://zerobin.net/?0eda2a5b3b30b534#Rv0QZyVP5OcmSDtjzkTqyJPih4D2o7nv5JH9qZc7SEs=

here is the js file that is generated and the link i got it from https://3ehro.sse.codesandbox.io/_nuxt/ec0f4ba.js

Do note that the generated js file is 1.4mb in size

Blakeinstein avatar Feb 02 '22 13:02 Blakeinstein

Describe the bug An unminified inlinded css as a js template string is added to built files when using vue-fontawesome with nuxt3.

Reproducible test case https://codesandbox.io/s/compassionate-leavitt-3ehro?file=/plugins/fontawesome.ts Here is a repro of this issue. Simple open the preview window in a new window then check the js files generated in the dev console (in sources/debugger tab). This has been a major hurdle in me getting a decent lighthouse score.

Expected behavior With config.autoAddCss = false no css should exist in the build files.

Desktop (please complete the following information):

  • Browser : all
  • Version: "@fortawesome/vue-fontawesome": "3.0.0-5"

Additional context I have followed the instructions for nuxt, but that doesnt seem to fix it. Additionally, webpack 5 is being used as the bundler in nuxt3.

How did you use it with nuxt3? Is the .component() method available in the nuxtApp.vueApp?

ennioVisco avatar Feb 07 '22 21:02 ennioVisco

How did you use it with nuxt3? Is the .component() method available in the nuxtApp.vueApp?

Well in the reproduction, I created a plugin that registers the fontawesome component as Fa

Blakeinstein avatar Feb 08 '22 06:02 Blakeinstein

I'm having the same issue when using version 2.14.6`. The example is the same way I use font awesome in my project, and the entry point is 1.11mb.

ghost avatar Jun 21 '22 08:06 ghost

I'm having the same issue when using version 2.14.6`. The example is the same way I use font awesome in my project, and the entry point is 1.11mb.

I just recommend using https://github.com/antfu/unplugin-icons for a more modern experience.

ennioVisco avatar Jun 21 '22 09:06 ennioVisco

Importing each icon individually should resolve the issue.

import { faUser } from '@fortawesome/free-solid-svg-icons/faUser'

P4sca1 avatar Nov 03 '22 12:11 P4sca1

Same issue here, it's generating a massive file, that's way too big for production

image

I use hundreds of icons, so importing them all manually is a no-go. Any way to fix this and only import the modules that were used?

jeannen avatar Nov 21 '23 12:11 jeannen