在我的反應應用程序我想用webpack和css加載器使用fontawesome css文件。我的配置是這樣的:webpack使用字體真棒
的WebPack配置
module: {
rules: [
{
test: /\.js?$/,
loader: 'babel-loader',
options: {
presets: [
["es2015", { modules: false }],
"stage-2",
"react"
],
plugins: [
"transform-node-env-inline"
],
env: {
development: {
plugins: ["react-hot-loader/babel"]
}
}
}
}, {
test: /\.(eot|ttf|woff2?|otf|svg|png|jpg)$/,
loaders: ['file']
},
{
test: /\.css$/,
use: [
"style-loader",
{
loader: "css-loader",
options: {
modules: true,
sourceMap: true,
importLoaders: 1,
localIdentName: "[name]--[local]--[hash:base64:8]"
}
},
"postcss-loader" // has separate config, see postcss.config.js nearby
]
},
]
在index.js我有這樣的:
import 'font-awesome/css/font-awesome.css';
,並在渲染方法,我有這樣的:
<li><NavLink to="/dashboard" className="fa fa-bars" activeClassName="activeSidebar"
aria-hidden="true"></NavLink></li>
有沒有錯誤,但也沒有顯示圖標......我的錯誤是什麼?
感謝
什麼都沒有改變 – Felix