I downloaded some icons via flaticon. Now I'm trying to use an icon in my component but something goes wrong. I'm importing the css inside my component, and had my webpack.config.json set to load all the font files using file-loader.
what am i doing wrong?
my loaders in webpack.config.json:
loaders: [
{
test: /\.(jpe?g|png|gif|svg|eot|ttf|woff)$/i,
loader: 'file-loader',
query:{
hash:'sha512',
digest:'hex',
name:'[hash].[ext]'
}
},
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['react'],
}
},
{
test: /\.css$/,
exclude: /(node_modules|bower_components)/,
loader: combineLoaders([
{
loader: 'style-loader'
}, {
loader: 'css-loader',
query: {
modules: true,
camelCase: 'dashes',
localIdentName: '[name]__[local]___[hash:base64:5]'
}
}
])
}
]
my component - LocationIndicator.js:
import React from 'react';
import locationFonts from '../../../location-fonts/flaticon.css';
var LocationIndicator = React.createClass({
render: function () {
return(
<span className={locationFonts['flaticon-cactus']}></span>
);
}
});
export default LocationIndicator;
flaticon.css:
/*
Flaticon icon font: Flaticon
Creation date: 24/02/2017 14:52
*/
@font-face {
font-family: "Flaticon";
src: url("./Flaticon.eot");
src: url("./Flaticon.eot?#iefix") format("embedded-opentype"),
url("./Flaticon.woff") format("woff"),
url("./Flaticon.ttf") format("truetype"),
url("./Flaticon.svg#Flaticon") format("svg");
font-weight: normal;
font-style: normal;
}
@media screen and (-webkit-min-device-pixel-ratio:0) {
@font-face {
font-family: "Flaticon";
src: url("./Flaticon.svg#Flaticon") format("svg");
}
}
[class^="flaticon-"]:before, [class*=" flaticon-"]:before,
[class^="flaticon-"]:after, [class*=" flaticon-"]:after {
font-family: Flaticon;
font-size: 20px;
font-style: normal;
margin-left: 20px;
}
.flaticon-cactus:before { content: "\f100"; }
.flaticon-desert-cactus:before { content: "\f101"; }
.flaticon-location:before { content: "\f102"; }
.flaticon-map-marker:before { content: "\f103"; }
.flaticon-map-with-position-marker:before { content: "\f104"; }
.flaticon-placeholder-circle:before { content: "\f105"; }
.flaticon-placeholder-map:before { content: "\f106"; }
the ttf, eot, woff, svg file are at the same location as the css
thanks!
edit: I'm adding a print screen of the source code after compilation, the file names and references still match...