大家好,我正在尝试使用webpack从@ mdi / font库加载一些SCSS。但是我总是收到“找不到模块”。我该如何解决这个问题?
style.scss
@import '../../node_modules/@mdi/font/scss/materialdesignicons.scss';
webpack.config.js
...
{
test: /\.scss$/,
use: [{
loader: 'style-loader',
}, {
loader: 'css-loader',
}, {
loader: 'sass-loader',
options: {
includePaths: ['./node_modules/'],
},
}],
}, {
test: /\.css$/,
use: [{
loader: 'style-loader',
}, {
loader: 'css-loader',
}],
},
{
test: /\.(jpeg|jpg|png|gif|svg)$/i,
use: {
loader: 'url-loader',
options: {
name: '[hash].[ext]',
},
},
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff',
},
{test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'file-loader'},
],
},
...
};
错误日志
ERROR in ./src/style/style.scss (./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/lib/loader.js??ref--5-2!./src/style/style.scss)
Module not found: Error: Can't resolve '../fonts/materialdesignicons-webfont.ttf?v=3.5.95' in 'F:\slimhub-mobile\src\style'
@ ./src/style/style.scss (./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/lib/loader.js??ref--5-2!./src/style/style.scss) 8:41-101
@ ./src/style/style.scss
@ ./src/index.js