1 回答
TA贡献1825条经验 获得超6个赞
您可以简单地为不同的图像集多次包含插件,并对每个图像应用不同的 imagemin 设置:
module.exports = {
plugins: [
new ImageminPlugin({
externalImages: {
context: '.',
sources: glob.sync('img/**/*.{png,jpg,jpeg,gif,svg}'),
destination: 'img',
fileName: '../[path][name].[ext]'
},
pngquant: ({quality: '80-100'}),
plugins: [
imageminMozjpeg({quality: 80, progressive: true}),
imageminSvgo()
],
jpegtran: {progressive: true}
}),
new ImageminPlugin({
externalImages: {
context: '.',
sources: glob.sync('pages/**/*.{png,jpg,jpeg,gif,svg}'),
destination: 'img',
fileName: '../[path][name].[ext]'
},
pngquant: ({quality: '80-100'}),
plugins: [
imageminMozjpeg({quality: 80, progressive: true}),
imageminSvgo()
],
jpegtran: {progressive: true}
})
],
module: {
rules: [
{
test: /\.(png|jpe?g|gif|svg)$/i,
use: [
{
loader: 'file-loader',
options: {
name: '../[path][name].[ext]'
}
}
]
},
]
}
}
添加回答
举报