【发布时间】:2021-07-05 13:41:35
【问题描述】:
简而言之,这里有我的 webpack(下面,我放了相关的代码)。
实际上,webpack 使用字体的 svg 创建图像文件夹,而不是 svg 图像。 (截图如下)
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader',
},
{
test: /\.(sa|sc|c)ss$/,
exclude: /node_modules/,
use: [
'style-loader', // Creates `style` nodes from JS strings
'css-loader', // Translates CSS into CommonJS
'sass-loader', // Compiles Sass to CSS
],
},
{
test: /\.(png|svg|jpg|gif)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'image/'
}
}
]
},
{
test: /\.(woff(2)?|ttf|otf|eot)(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'font/'
}
}
]
}
]
},
这是我的 HTML:
<div class="cc-header__left">
<img src="image/LOGO.svg" alt="logo conseil constitutionnel" />
<p class="cc-header__logoName"> Élection présidentielle <span>2022</span></p>
</div>
【问题讨论】: