I'm trying to add font-awesome to my Next.js project using webpack. I've tried following various instructions I've found on the web (using file-loader, url-loader), but nothing has worked for me. I gave up loading font-awesome with webpack for the moment, but I want to know how I can accomplish this. Currently, I have a .scss
file that I use to load font-awesome.
It's contents:
$fa-font-path: "static/fonts";
@import "~font-awesome/scss/font-awesome.scss";
And I'm manually moving the fonts from node_modules/font-awesome/fonts
to static/fonts
. This works perfectly, But I wanted to know if there's a webpack 2 way to do it in 2017.
There are a few ways to do this. The first would be to create a head component via next/head and import there - see here:
Another way is to create a HOC to wrap your pages with and import there with a simple import 'font-awesome/css/font-awesome.min.css'
Or, you could just import it into one of your page's with the same kind of import. (I believe this will scope it to that particular page however. Double check me on that)
Hope this helps.