mouhcinemahfoud's avatar

Font awesome in with laravel mix

Hello artisans, I have a problem with importing Fontawesome using npm and laravel mix. here is my use case: 1- I've created a new Laravel project 2- I've installed font-awesome through npm 3- I've added @import "~font-awesome/scss/font-awesome"; i get the following error: it looks for fonts in: http://localhost/fonts/fontawesome-webfont.woff2 instead of : http://localhost/public/fonts/fontawesome-webfont.woff2

my first (not working) solution was to add this $fa-font-path: "./public/fonts/"; to my app.scss file (that was stupid because of order load but it worth trying)

can anyone help?

PS: i don't wanna use a CDN nor a direct path using Thanks

0 likes
5 replies
ejdelmonico's avatar

For me, I just run the copy method to copy the fonts over to /public/fonts/ which is where font-awesome will look for the files unless you specify a new path. The, depending on the project, I either import the full node path into app.scss or run the script method to combine.

PaulClarke's avatar

If you add .copy('node_modules/font-awesome/fonts', 'public/fonts' to you mix file it should do the trick, or you can select individual files if needed.

mouhcinemahfoud's avatar
Level 24

it worked when i gave it the full path like this in my app.scss file

$fa-font-path: '/laralab/public/fonts/vendor/font-awesome';
@import '~font-awesome/scss/font-awesome';

but i think it's a terrible idea, i'm not going to use this solution for sure!

any other solutions please?

Please or to participate in this conversation.