Shopware 6 Using fontawesome in custom theme
Asked Answered
V

1

6

I need to use fontawesome in my custom theme. Therefor I installed it by using yarn yarn add @fortawesome/fontawesome-free

When I'm trying to import it (@import "~@fortawesome" ) within the base.scss of my theme I get the following error:

In ThemeCompiler.php line 317:
[Shopware\Storefront\Theme\Exception\ThemeCompileException]
Unable to compile the theme "CustomTheme". ~@fortawesome file not found for @import: custom/plugins/CustomTheme/src/Resources/app/storefront/src/scss/base.scss on line 2, at column 1
Call Stack:
#0 import custom/plugins/CustomTheme/src/Resources/app/storefront/src/scss/base.scss (unknown file) on line 409

Can someone please tell me how to import fa correctly into my scss-file?


EDIT: I installed fontawesome via npm inside my plugin under the following path plugin/src/Resources/app/storefront.

To import it in my base.scss I can't simply use ./@fortawesome/... like descirbed in the doc. I have to import the files like this ../../node_module/@fortawesome/... instead.

The other problem is that the system can't find/load the webfonts of fa. I know that a solution would be to copy the fonts manually into my public folder but is there a way to make shopware copy them and put them into the public folder throughout the compiling process?

Videogenic answered 7/7, 2022 at 10:47 Comment(1)
See also: #73195914Stableboy
V
4

It's working. Here is what I've done:

  • I installed fa via npm into the following folder src/Resources/app/storefront
  • I added the important paths to the theme.json (fontawesome, regular,solid, and brands to style and webfonts to assets)

Is this the way shopware wants fa to be implemented in a custom plugin?

Videogenic answered 1/8, 2022 at 10:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.