我需要在component添加configuration(模块)。怎么做对了?
我收到此错误:
[1] ERROR in ./node_modules/font-awesome/css/font-awesome.css
[1] Module parse failed: C:\Users\steko\Desktop\webpack-electron-react-sass-conf\node_modules\font-awesome\css\font-awesome.css Unexpected character '@' (7:0)
[1] You may need an appropriate loader to handle this file type.
[1] | /* FONT PATH
[1] | * -------------------------- */
[1] | @font-face {
[1] | font-family: 'FontAwesome';
[1] | src: url('../fonts/fontawesome-webfont.eot?v=4.7.0');
[1] @ ./node_modules/react-fa/lib/index.js 13:0-44
[1] @ ./src/AwesomeComponent.jsx
[1] @ ./src/index.jsx
这很奇怪,因为我为css添加了样式加载器。如何解决?
答案 0 :(得分:0)
尝试使用url loader来获取webpack.config中的字体文件
{
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?mimetype=application/font-woff',
},
{
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?mimetype=application/font-woff',
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?mimetype=application/octet-stream',
},
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader',
},
答案 1 :(得分:0)
@VINET您需要添加规则来处理webpack conf中的CSS文件。
尝试在配置中添加以下规则
{
test: /\.css$/,
loader: "style-loader!css-loader"
},