尝试使用Webpack加载font-awesome会导致以下错误:
我正在尝试在React组件中导入font-awesome,代码如下:
这是我的webpack.config.js文件。我想把font-awesome和相关资源与其他内容分开加载,原因是我已经使用babel加载了SVG,但不想这样做font-awesome。
我也尝试过这样做正则表达式,但它并没有起作用:
ERROR in ./~/font-awesome/fonts/fontawesome-webfont.eot?v=4.6.3
Module parse failed: ...\node_modules\font-awesome\fonts\fontawesome-webfont.eot?v=4.6.3 Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type.
我正在尝试在React组件中导入font-awesome,代码如下:
import "font-awesome/scss/font-awesome.scss";
这是我的webpack.config.js文件。我想把font-awesome和相关资源与其他内容分开加载,原因是我已经使用babel加载了SVG,但不想这样做font-awesome。
{
test: /\.scss/,
loader: ExtractPlugin.extract("style", "css!sass")
},
{
test: /\.svg$/,
loader: "babel!svg-react",
exclude: /node_modules/
},
{
test: /\.ttf$/,
loader: "file-loader?mimetype=application/octet-stream&name=[name].[ext]",
exclude: /node_modules/
},
{
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/font-woff&name=[name].[ext]",
exclude: /node_modules/
},
{
test: /\.(otf|eot|png|svg|ttf|woff|woff2)(\?[\s\S]+)?$/,
loader: "url?limit=10000",
include: "node_modules/font-awesome/fonts"
}
我也尝试过这样做正则表达式,但它并没有起作用:
{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url?limit=10000" }
(ttf|eot|svg|woff2?)
来完成吗? - The Guy with The Hat