Created
November 17, 2016 19:55
-
-
Save jdmorlan/d5fe0da83e737ca23178d35242669f51 to your computer and use it in GitHub Desktop.
Add Font-Awesome to Webpack!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('./sass/font-awesome/scss/font-awesome.scss') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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