other question約react-iconsがwebpackに読み込まれませんでしたが、私が得ているエラーは少し異なり、どのように修正するかわかりません。リアアイコンがwebpackでエラーを解決しました
私が反応し、アイコンをWebPACKのに使用しようとしているが、私は次のエラーを取得しています:ここで
ERROR in ./components/line-item.jsx Module not found: Error: Cannot resolve module 'react-icons' in public/map/components @ ./components/line-item.jsx 7:18-40
は私のWebPACKのセットアップです:私はどこここ
var path = require('path');
var webpack = require('webpack');
var config = {
iconPath: 'node_modules/react-icons'
};
module.exports = {
entry: './main.js',
output: {path: __dirname, filename: 'bundle.js'},
module: {
loaders: [
{
test: /.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react']
}
},
{
test: /react-icons\/(.)*(.js)$/,
loader: 'babel',
include: config.iconPath
},
{
test: /\.scss/,
loader: 'style!css!sass'
}
]
}
};
ですWebPACKのに
import React from 'react';
import FaBeer from 'react-icons';
var LineItem = React.createClass({
})
module.exports = LineItem;
私は新しいブランドを私のライン-item.jsxで反応し、アイコンをインポートしようと、私は府に行くんだとちょうど学習どんな助けでも大歓迎です。
EDIT: 私は
import FaBeer from 'react-icons/fa/beer';
にインポートを変更し、今、私は信じていない別のエラーを取得することはWebPACKの
ERROR in ./~/react-icons/fa/beer.js Module parse failed: /Users/oyachinskiy/Documents/ichnaea-root/web-reporting/public/map/node_modules/react-icons/fa/beer.js Unexpected token (8:12) You may need an appropriate loader to handle this file type.
感謝を関連しています!
を置くことが必要です。私は単にそれを要求しようとすると同じエラーが発生します。 – yoleg
私の編集した回答を参照してください。あなたの構文はドキュメントと一致しません。 – Toby
これを行うと、別のエラーが発生します。エラー:./~/react-icons/fa/beer.js モジュールの解析でweb-reporting/public/map/node_modules/react-icons/fa/beerが失敗しました。 js予期しないトークン(8:12) このファイルタイプを処理するには、適切なローダーが必要な場合があります。これが私がwebpackの設定を編集する必要があると思う理由です – yoleg