Skip to content

Instantly share code, notes, and snippets.

@jdmorlan
Created November 17, 2016 19:55
Show Gist options
  • Save jdmorlan/d5fe0da83e737ca23178d35242669f51 to your computer and use it in GitHub Desktop.
Save jdmorlan/d5fe0da83e737ca23178d35242669f51 to your computer and use it in GitHub Desktop.
Add Font-Awesome to Webpack!
// React component to place Font Awesome items on the page!
import React, { PropTypes } from 'react'
import cx from 'classnames'
const Icon = React.createClass({
propTypes: {
name: PropTypes.string.isRequired,
classNames: PropTypes.string
},
_buildClassNames () {
const { name } = this.props
const fontAwesomeClassName = `fa fa-${name}`
return cx(fontAwesomeClassName, this.props.classNames)
},
render () {
const classNames = this._buildClassNames()
return(
<i className={classNames} aria-hidden="true"></i>
)
}
})
export const Icon
require('./sass/font-awesome/scss/font-awesome.scss')

Download Font Awesome, place fonts/scss in your sass folder

// Place in webpack config (loaders) section
{test: /\.scss$/, loader: ExtractTextPlugin.extract('style', 'css!sass')},
{
test: /\.(eot|svg|ttf|woff(2)?)(\?v=\d+\.\d+\.\d+)?/,
loader: 'url'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment