I am trying to import Font Awesome into my Symfony 5 with Webpack Encore project but I can't. I have read all the (most of them) S.O questions, framework tutorials, etc. but none of the icons are being displayed.
Steps I followed:
First attempt:
- Compile assets and watch for changes with
yarn watch - Install Font Awesome Free:
yarn add --dev @fortawesome/fontawesome-free - Import CSS files into
app.cssfile (assets/css/app.css):
@import '~@fortawesome/fontawesome-free/css/fontawesome.css';
@import '~@fortawesome/fontawesome-free/css/regular.css';
@import '~@fortawesome/fontawesome-free/css/solid.css';
@import '~@fortawesome/fontawesome-free/css/brands.css';
- Add the icon to the TWIG template:
<i class="fas fa-star"></i>( I also tried to prepend the icon withfa fa-star, according to Font Awesome documentation.
Second attempt:
- Compile assets and watch for changes with
yarn watch - Install Font Awesome Free:
yarn add --dev @fortawesome/fontawesome-free - Import CSS / JS files into
app.jsfile (assets/js/app.js):
import '~@fortawesome/fontawesome-free/css/all.min.css';
import '~@fortawesome/fontawesome-free/js/all.js';
- Import Solid Font Awesome icons into CSS file (
assets/css/app.css) (and also in JS file):
@import '~@fortawesome/fontawesome-free/css/solid.css';
- Add the icon to the TWIG template:
<i class="fas fa-star"></i>
I also have tried using CSS unicode:
element {
content: "\f005"
}
None of them displays any icon, or any console error, warning, message, or anything, but I get an empty icon every time. Any clues?