Ich habe einige Icons über das flaticon heruntergeladen. Jetzt versuche ich ein Symbol in meiner Komponente zu verwenden, aber etwas schief geht. Ich importiere das CSS innerhalb meiner Komponente und ließ meine Datei webpack.config.json so einstellen, dass alle Schriftdateien mit dem Datei-Loader geladen werden.Laden von Schriftarten Icons mit React
was mache ich falsch?
meine Lader 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]'
}
}
])
}
]
meine Komponente - 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"; }
die ttf, EOT, Woff, Svg-Datei sind an der gleichen Stelle wie die css
danke!
edit: Ich bin ein Druckbild des Quellcodes nach der Kompilierung hinzugefügt, die Dateinamen und Verweise noch passen ...
Welchen Fehler haben Sie? – fhelwanger
Das ist der Spaß Teil, ich bekomme keinen Fehler –