在我的样式中,我有这样的字体定义:
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: local('Material Icons'), local('MaterialIcons-Regular'),
url(/fonts/MaterialIcons-Regular.woff2) format('woff2'),
url(/fonts/MaterialIcons-Regular.woff) format('woff'),
url(/fonts/MaterialIcons-Regular.ttf) format('truetype');
}
字符串
在我将css-loader
更新到新版本4.0.0(几天前发布)后,我得到了这些错误(building bundle):
./src/index.scss模块生成失败(从./node_modules/css-loader/dist/cjs.js):错误:无法解析'D:\cot\EDelivery\EDelivery.Injected.AspCore.RegWebApp\src'中的'/fonts/MaterialIcons-Regular. woff 2' at doResolve(D:\cot\EDelivery\EDelivery\EDelivery.Injected.AspCore.RegWebApp\node_modules\enhanced-resolve\lib\Resolver.js:209:21)at hook.callAsync(D:\cot\EDelivery\EDelivery\EDelivery.Injected.AspCore.RegWebApp\node_modules\enhanced-resolve\lib\Resolver.js:285:5)at _fn0(eval at create(D:\cot\EDelivery\EDelivery\EDelivery.Injected.AspCore.RegWebApp\node_modules\tapable\lib\HookCodeFactory.js:32:10),:15:1)
在新版本中,css-loader
似乎试图使字体嵌入。如何禁用此行为?(无法找到该选项:https://webpack.js.org/loaders/css-loader/)
我的配置是:
{
test: /\.(scss|css)$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
sourceMap: true
}
},
{ // ... postcss-loader, sass-loader
型
2条答案
按热度按时间ac1kyiln1#
而不是loader:“css-loader”,你可以像这样传递额外的参数来禁用该功能。
"css-loader?url=false"
fae0ux8s2#
将
url: false
选项添加到css和scss加载器字符串